Removed unnecessary code duplication.
This commit is contained in:
parent
59139b17cb
commit
8022baec2a
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue