Improve speed a lot for files that have long number lists like = { 0,1,2,3,4, etc. }

This commit is contained in:
Reijo Tomperi 2009-08-05 23:02:40 +03:00
parent ce8c5b0236
commit eb691857fd
1 changed files with 15 additions and 17 deletions

View File

@ -1549,7 +1549,6 @@ void Tokenizer::simplifyTokenList()
}
simplifyComma();
createLinks();
if (_settings && _settings->_debug)
{
_tokens->printOut();
@ -3258,26 +3257,25 @@ void Tokenizer::syntaxError(const Token *tok, char c)
bool Tokenizer::simplifyComma()
{
bool ret = false;
bool insideLoop = false;
size_t indentlevel = 0;
createLinks();
for (Token *tok = _tokens; tok; tok = tok->next())
{
if (tok->str() == "(")
if (Token::simpleMatch(tok, "for ("))
{
++indentlevel;
tok = tok->next()->link();
if (!tok)
break;
continue;
}
else if (tok->str() == ")")
if (Token::simpleMatch(tok, "= {"))
{
--indentlevel;
if (indentlevel == 0)
{
insideLoop = false;
}
}
else if (tok->str() == "for")
{
insideLoop = true;
tok = tok->next()->link();
if (!tok)
break;
continue;
}
if (tok->str() != ",")
@ -3306,7 +3304,7 @@ bool Tokenizer::simplifyComma()
{
for (Token *tok2 = tok->previous(); tok2; tok2 = tok2->previous())
{
if (tok2->str() == "=" && !insideLoop)
if (tok2->str() == "=")
{
// Handle "a = 0, b = 0;"
tok->str(";");