Optimization Tokenizer::simplifyMathFunctions. Make an a priori check whether the token combination can be a function call at all.

This commit is contained in:
Frank Zingsheim 2014-03-09 13:22:58 +01:00 committed by Daniel Marjamäki
parent b13e3ac549
commit 6e9e20d5b1
1 changed files with 235 additions and 232 deletions

View File

@ -8241,6 +8241,8 @@ bool Tokenizer::simplifyMathFunctions()
{ {
bool simplifcationMade = false; bool simplifcationMade = false;
for (Token *tok = list.front(); tok; tok = tok->next()) { for (Token *tok = list.front(); tok; tok = tok->next()) {
const Token * tokNext = tok->next();
if (tokNext && tokNext->str() == "(") { // precondition for function
if (Token::Match(tok, "atol ( %str% )")) { //@todo Add support for atoll() if (Token::Match(tok, "atol ( %str% )")) { //@todo Add support for atoll()
if (tok->previous() && if (tok->previous() &&
Token::simpleMatch(tok->tokAt(-2), "std ::")) { Token::simpleMatch(tok->tokAt(-2), "std ::")) {
@ -8489,6 +8491,7 @@ bool Tokenizer::simplifyMathFunctions()
} }
} }
} }
}
// returns true if a simplifcation was performed and false otherwise. // returns true if a simplifcation was performed and false otherwise.
return simplifcationMade; return simplifcationMade;
} }