Minor improvement to removeReduntantConditions()

This commit is contained in:
Reijo Tomperi 2008-12-24 08:33:15 +00:00
parent 36f39aec22
commit 05e23b7606
1 changed files with 6 additions and 20 deletions

View File

@ -1078,30 +1078,16 @@ bool Tokenizer::removeReduntantConditions()
for ( TOKEN *tok = _tokens; tok; tok = tok->next() )
{
if (!TOKEN::Match(tok, "if ( %bool% )"))
if (!TOKEN::Match(tok, "if ( %bool% ) {"))
continue;
// Find matching else
const TOKEN *elseTag = 0;
if( TOKEN::simpleMatch( tok->tokAt( 4 ), "{" ) )
{
// Find the closing "}"
elseTag = Tokenizer::findClosing( tok->tokAt( 4 ) );
if( elseTag )
elseTag = elseTag->next();
}
else
{
// Find the closing ";"
for ( const TOKEN *closing = tok->tokAt( 4 ); closing; closing = closing->next() )
{
if( closing->str() == ";" )
{
elseTag = closing->next();
break;
}
}
}
// Find the closing "}"
elseTag = Tokenizer::findClosing( tok->tokAt( 4 ) );
if( elseTag )
elseTag = elseTag->next();
bool boolValue = false;
if( tok->tokAt( 2 )->str() == "true" )