Removed unnecessary code duplication.

This commit is contained in:
Pete Johns 2010-10-27 19:34:06 +11:00
parent 59139b17cb
commit 8022baec2a
2 changed files with 23 additions and 17 deletions

View File

@ -2128,14 +2128,7 @@ bool Tokenizer::tokenize(std::istream &code,
_tokens->assignProgressValues();
// remove redundant semicolon:
for (Token *tok = _tokens; tok; tok = tok->next())
{
if (tok->str() == "(")
tok = tok->link();
while (Token::simpleMatch(tok, "; ;"))
tok->deleteNext();
}
removeRedundantSemicolons();
return validate();
}
@ -3954,15 +3947,7 @@ bool Tokenizer::simplifyTokenList()
_tokens->assignProgressValues();
// remove redundant semicolon:
for (Token *tok = _tokens; tok; tok = tok->next())
{
if (tok->str() == "(")
tok = tok->link();
while (Token::simpleMatch(tok, "; ;"))
tok->deleteNext();
}
removeRedundantSemicolons();
return validate();
}
@ -4151,6 +4136,22 @@ bool Tokenizer::removeReduntantConditions()
}
void Tokenizer::removeRedundantSemicolons()
{
for (Token *tok = _tokens; tok; tok = tok->next())
{
if (tok->str() == "(")
{
tok = tok->link();
}
while (Token::simpleMatch(tok, "; ;"))
{
tok->deleteNext();
}
}
}
void Tokenizer::simplifyIfAddBraces()
{
for (Token *tok = _tokens; tok; tok = tok ? tok->next() : NULL)

View File

@ -290,6 +290,11 @@ public:
*/
bool removeReduntantConditions();
/**
* Reduces "; ;" to ";", except in "( ; ; )"
*/
void removeRedundantSemicolons();
/** Simplify function calls - constant return value
* @return true if something is modified
* false if nothing is done.