Remove repeated search, clearer code

This commit is contained in:
Dmitry-Me 2015-10-15 16:48:35 +03:00
parent 04a31011b0
commit 64bdf03986
1 changed files with 3 additions and 2 deletions

View File

@ -3133,11 +3133,12 @@ bool Tokenizer::simplifySizeof()
// sizeof( a )
else if (Token::Match(tok->next(), "( %var% )")) {
if (sizeOfVar.find(tok->tokAt(2)->varId()) != sizeOfVar.end()) {
std::map<unsigned int, unsigned int>::const_iterator sizeOfVarPos = sizeOfVar.find(tok->tokAt(2)->varId());
if (sizeOfVarPos != sizeOfVar.end()) {
tok->deleteNext();
tok->deleteThis();
tok->deleteNext();
tok->str(MathLib::toString(sizeOfVar[tok->varId()]));
tok->str(MathLib::toString(sizeOfVarPos->second));
ret = true;
} else {
// don't try to replace size of variable if variable has