From eb691857fd388b6420a202dea12817142ef37921 Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Wed, 5 Aug 2009 23:02:40 +0300 Subject: [PATCH] Improve speed a lot for files that have long number lists like = { 0,1,2,3,4, etc. } --- src/tokenize.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/tokenize.cpp b/src/tokenize.cpp index fa87f205d..5227a5549 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -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(";");