made valueFlowSwitchVariable faster when there are many 'case %num%:'

This commit is contained in:
Daniel Marjamäki 2015-07-27 14:57:02 +02:00
parent 05a21d45eb
commit f449e91d43
1 changed files with 3 additions and 1 deletions

View File

@ -2020,8 +2020,10 @@ static void valueFlowSwitchVariable(TokenList *tokenlist, SymbolDatabase* symbol
if (Token::Match(tok, "case %num% :")) { if (Token::Match(tok, "case %num% :")) {
std::list<ValueFlow::Value> values; std::list<ValueFlow::Value> values;
values.push_back(ValueFlow::Value(MathLib::toLongNumber(tok->next()->str()))); values.push_back(ValueFlow::Value(MathLib::toLongNumber(tok->next()->str())));
while (Token::Match(tok->tokAt(3), "case %num% :")) { while (Token::Match(tok->tokAt(3), ";| case %num% :")) {
tok = tok->tokAt(3); tok = tok->tokAt(3);
if (!tok->isName())
tok = tok->next();
values.push_back(ValueFlow::Value(MathLib::toLongNumber(tok->next()->str()))); values.push_back(ValueFlow::Value(MathLib::toLongNumber(tok->next()->str())));
} }
for (std::list<ValueFlow::Value>::const_iterator val = values.begin(); val != values.end(); ++val) { for (std::list<ValueFlow::Value>::const_iterator val = values.begin(); val != values.end(); ++val) {