From 05e23b760670c6d0049f3704f320e4d7e3bf8d8f Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Wed, 24 Dec 2008 08:33:15 +0000 Subject: [PATCH] Minor improvement to removeReduntantConditions() --- tokenize.cpp | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/tokenize.cpp b/tokenize.cpp index de9fc450e..823be8f0c 100644 --- a/tokenize.cpp +++ b/tokenize.cpp @@ -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" )