tokenize : optimising "simplifyConditions"

This commit is contained in:
Daniel Marjamäki 2008-12-24 07:55:12 +00:00
parent a65a66bee0
commit 36f39aec22
1 changed files with 4 additions and 1 deletions

View File

@ -1333,9 +1333,12 @@ bool Tokenizer::simplifyConditions()
}
// Reduce "(%num% == %num%)" => "(true)"/"(false)"
const TOKEN *tok4 = tok->tokAt(4);
if ( ! tok4 )
break;
if ( (tok->str()=="&&" || tok->str()=="||" || tok->str()=="(") &&
TOKEN::Match(tok->tokAt(1), "%num% %any% %num%") &&
(TOKEN::simpleMatch(tok->tokAt(4), "&&") || TOKEN::simpleMatch(tok->tokAt(4), "||") || TOKEN::simpleMatch(tok->tokAt(4), ")")) )
(tok4->str()=="&&" || tok4->str()=="||" || tok4->str()==")") )
{
double op1 = (strstr(tok->strAt(1), "0x")) ? strtol(tok->strAt(1),0,16) : atof( tok->strAt(1) );
double op2 = (strstr(tok->strAt(3), "0x")) ? strtol(tok->strAt(3),0,16) : atof( tok->strAt(3) );