Optimization: Skip over expression in brackets in Tokenizer::isFunctionParameterPassedByValue()

This commit is contained in:
PKEuS 2015-12-10 15:53:14 +01:00
parent 37572dc109
commit 51bb76c5b5
1 changed files with 7 additions and 12 deletions

View File

@ -7954,22 +7954,17 @@ bool Tokenizer::isFunctionParameterPassedByValue(const Token *fpar) const
const Token *ftok; const Token *ftok;
// Look at function call, what parameter number is it? // Look at function call, what parameter number is it?
unsigned int parentheses = 1;
unsigned int parameter = 1; unsigned int parameter = 1;
for (ftok = fpar->previous(); ftok; ftok = ftok->previous()) { for (ftok = fpar->previous(); ftok; ftok = ftok->previous()) {
if (ftok->str() == "(") { if (ftok->str() == "(")
--parentheses;
if (parentheses == 0) {
break; break;
} else if (ftok->str() == ")")
} else if (ftok->str() == ")") { ftok = ftok->link();
++parentheses; else if (ftok->str() == ",")
} else if (parentheses == 1 && ftok->str() == ",") {
++parameter; ++parameter;
} else if (Token::Match(ftok, "[;{}]")) { else if (Token::Match(ftok, "[;{}]"))
break; break;
} }
}
// Is this a function call? // Is this a function call?
if (ftok && Token::Match(ftok->tokAt(-2), "[;{}=] %name% (")) { if (ftok && Token::Match(ftok->tokAt(-2), "[;{}=] %name% (")) {