Omit repeated computations

This commit is contained in:
Dmitry-Me 2017-09-05 17:56:57 +03:00
parent 0e444aa133
commit 3127fcf429
1 changed files with 9 additions and 7 deletions

View File

@ -4048,15 +4048,17 @@ void Tokenizer::removeMacrosInGlobalScope()
void Tokenizer::removeMacroInClassDef() void Tokenizer::removeMacroInClassDef()
{ {
for (Token *tok = list.front(); tok; tok = tok->next()) { for (Token *tok = list.front(); tok; tok = tok->next()) {
if (Token::Match(tok, "class|struct %name% %name% {|:") && if (!Token::Match(tok, "class|struct %name% %name% {|:"))
(tok->next()->isUpperCaseName() || tok->tokAt(2)->isUpperCaseName())) { continue;
if (tok->next()->isUpperCaseName() && !tok->tokAt(2)->isUpperCaseName())
const bool nextIsUppercase = tok->next()->isUpperCaseName();
const bool afterNextIsUppercase = tok->tokAt(2)->isUpperCaseName();
if (nextIsUppercase && !afterNextIsUppercase)
tok->deleteNext(); tok->deleteNext();
else if (!tok->next()->isUpperCaseName() && tok->tokAt(2)->isUpperCaseName()) else if (!nextIsUppercase && afterNextIsUppercase)
tok->next()->deleteNext(); tok->next()->deleteNext();
} }
} }
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------