From 269286669401455106c29714d89022dd707910b0 Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Wed, 24 Dec 2008 15:43:05 +0000 Subject: [PATCH] Cleanup to removeReduntantConditions() --- tokenize.cpp | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/tokenize.cpp b/tokenize.cpp index 823be8f0c..21f46e6b1 100644 --- a/tokenize.cpp +++ b/tokenize.cpp @@ -1078,7 +1078,10 @@ bool Tokenizer::removeReduntantConditions() for ( TOKEN *tok = _tokens; tok; tok = tok->next() ) { - if (!TOKEN::Match(tok, "if ( %bool% ) {")) + if (!TOKEN::simpleMatch(tok, "if")) + continue; + + if (!TOKEN::Match(tok->tokAt(1), "( %bool% ) {")) continue; // Find matching else @@ -1141,29 +1144,6 @@ bool Tokenizer::removeReduntantConditions() // Remove the "else { aaa; }" TOKEN::eraseTokens( elseTag->previous(), end->tokAt( 1 ) ); } - else - { - // Convert "if( true ) {aaa;} else bbb;" => "{aaa;}" - - // Find the closing ";" - const TOKEN *end = 0; - for ( const TOKEN *closing = elseTag->tokAt( 1 ); closing; closing = closing->next() ) - { - if( closing->str() == ";" ) - { - end = closing; - break; - } - } - - if( !end ) - { - // Possibly syntax error - return false; - } - - TOKEN::eraseTokens( elseTag->previous(), end->next() ); - } // Remove "if( true )" if( tok->previous() )