Optimizing setVarId()

This commit is contained in:
Reijo Tomperi 2008-12-27 20:48:42 +00:00
parent 31e9a7e10c
commit 7a9a43390e
1 changed files with 4 additions and 3 deletions

View File

@ -664,14 +664,15 @@ void Tokenizer::setVarId()
for ( TOKEN *tok = _tokens; tok; tok = tok->next() ) for ( TOKEN *tok = _tokens; tok; tok = tok->next() )
{ {
if ( tok->varId() != 0 && if ( tok->varId() != 0 &&
TOKEN::Match(tok, "%var% . %var%") && TOKEN::Match(tok->next(), ". %var%") &&
tok->tokAt(2)->varId() == 0 ) tok->tokAt(2)->varId() == 0 )
{ {
++_varId; ++_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() ) 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 ); tok2->next()->next()->varId( _varId );
} }
} }