Merge pull request #694 from Dmitry-Me/omitRepeatedSearch

Remove repeated search, clearer code
This commit is contained in:
PKEuS 2015-10-15 16:01:28 +02:00
commit 430e31ec1e
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