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();
|
_tokens->assignProgressValues();
|
||||||
|
|
||||||
// remove redundant semicolon:
|
removeRedundantSemicolons();
|
||||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
|
||||||
{
|
|
||||||
if (tok->str() == "(")
|
|
||||||
tok = tok->link();
|
|
||||||
while (Token::simpleMatch(tok, "; ;"))
|
|
||||||
tok->deleteNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
return validate();
|
return validate();
|
||||||
}
|
}
|
||||||
|
@ -3954,15 +3947,7 @@ bool Tokenizer::simplifyTokenList()
|
||||||
|
|
||||||
_tokens->assignProgressValues();
|
_tokens->assignProgressValues();
|
||||||
|
|
||||||
// remove redundant semicolon:
|
removeRedundantSemicolons();
|
||||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
|
||||||
{
|
|
||||||
if (tok->str() == "(")
|
|
||||||
tok = tok->link();
|
|
||||||
while (Token::simpleMatch(tok, "; ;"))
|
|
||||||
tok->deleteNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return validate();
|
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()
|
void Tokenizer::simplifyIfAddBraces()
|
||||||
{
|
{
|
||||||
for (Token *tok = _tokens; tok; tok = tok ? tok->next() : NULL)
|
for (Token *tok = _tokens; tok; tok = tok ? tok->next() : NULL)
|
||||||
|
|
|
@ -290,6 +290,11 @@ public:
|
||||||
*/
|
*/
|
||||||
bool removeReduntantConditions();
|
bool removeReduntantConditions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reduces "; ;" to ";", except in "( ; ; )"
|
||||||
|
*/
|
||||||
|
void removeRedundantSemicolons();
|
||||||
|
|
||||||
/** Simplify function calls - constant return value
|
/** Simplify function calls - constant return value
|
||||||
* @return true if something is modified
|
* @return true if something is modified
|
||||||
* false if nothing is done.
|
* false if nothing is done.
|
||||||
|
|
Loading…
Reference in New Issue