From 7a9a43390e6f8620fcc6025acf90825ff9f08cd9 Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Sat, 27 Dec 2008 20:48:42 +0000 Subject: [PATCH] Optimizing setVarId() --- tokenize.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tokenize.cpp b/tokenize.cpp index ad679cae5..10cadf1b9 100644 --- a/tokenize.cpp +++ b/tokenize.cpp @@ -664,14 +664,15 @@ void Tokenizer::setVarId() for ( TOKEN *tok = _tokens; tok; tok = tok->next() ) { if ( tok->varId() != 0 && - TOKEN::Match(tok, "%var% . %var%") && + TOKEN::Match(tok->next(), ". %var%") && tok->tokAt(2)->varId() == 0 ) { ++_varId; - const std::string pattern(std::string("%varid% . ") + tok->strAt(2)); + + const std::string pattern(std::string(". ") + tok->strAt(2)); for ( TOKEN *tok2 = tok; tok2; tok2 = tok2->next() ) { - if ( TOKEN::Match(tok2, pattern.c_str(), 0, tok->varId()) ) + if ( tok2->varId() == tok->varId() && TOKEN::simpleMatch( tok->next(), pattern.c_str() ) ) tok2->next()->next()->varId( _varId ); } }