diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2009-11-16 18:00:20 +0100 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2009-11-16 18:01:50 +0100 |
commit | 0b641d38d50bd6dc7b54cac5136b77827a71264e (patch) | |
tree | f5cca10629b404d33a06448ee3815ea09f8d2152 /src/shared/cplusplus/Parser.cpp | |
parent | 881f62e965e3d5f3b5aff3ce12f4efc879a2467a (diff) | |
download | qt-creator-0b641d38d50bd6dc7b54cac5136b77827a71264e.tar.gz |
Use a map for the memoization.
Diffstat (limited to 'src/shared/cplusplus/Parser.cpp')
-rw-r--r-- | src/shared/cplusplus/Parser.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index ca26cb629e..bad5233f02 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -441,6 +441,8 @@ bool Parser::parseTranslationUnit(TranslationUnitAST *&node) rewind(start_declaration + 1); skipUntilDeclaration(); } + + _templateArgumentList.clear(); } node = ast; @@ -568,6 +570,8 @@ bool Parser::parseLinkageBody(DeclarationAST *&node) rewind(start_declaration + 1); skipUntilDeclaration(); } + + _templateArgumentList.clear(); } match(T_RBRACE, &ast->rbrace_token); node = ast; @@ -692,11 +696,9 @@ bool Parser::parseOperatorFunctionId(NameAST *&node) Parser::TemplateArgumentListEntry *Parser::templateArgumentListEntry(unsigned tokenIndex) { - for (unsigned i = 0; i < _templateArgumentList.size(); ++i) { - TemplateArgumentListEntry *entry = &_templateArgumentList[i]; - if (entry->index == tokenIndex) - return entry; - } + std::map<unsigned, TemplateArgumentListEntry>::iterator it =_templateArgumentList.find(tokenIndex); + if (it != _templateArgumentList.end()) + return &it->second; return 0; } @@ -729,11 +731,11 @@ bool Parser::parseTemplateArgumentList(TemplateArgumentListAST *&node) } } - _templateArgumentList.push_back(TemplateArgumentListEntry(start, cursor(), node)); + _templateArgumentList.insert(std::make_pair(cursor(), TemplateArgumentListEntry(start, cursor(), node))); return true; } - _templateArgumentList.push_back(TemplateArgumentListEntry(start, cursor(), 0)); + _templateArgumentList.insert(std::make_pair(cursor(), TemplateArgumentListEntry(start, cursor(), 0))); return false; } |