aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/cplusplus/Parser.h
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@digia.com>2014-07-17 12:56:28 +0200
committerNikolai Kosjar <nikolai.kosjar@digia.com>2014-07-24 12:06:50 +0200
commitd3c5fff66de034e46e825b63943909d36067405f (patch)
treeba093e105a68c9f576f871dd010b14a04d70ddbf /src/libs/3rdparty/cplusplus/Parser.h
parent1926493fe9b8e621cf28736ec1486884d2edb334 (diff)
C++: Fix expensive parsing of expressions
For expression statements like "(g(g(g(...(g(0))...))))" we reparsed quite much again and again for nothing. The high-level trace for this expression looks like this: parseCastExpression parseTypeId parseAbstractDeclarator parseAbstractCoreDeclarator parseParameterDeclarationClause (--> DEEP) ... parseUnaryExpression ... parseCorePostfixExpression parseTypeId (--> DEEP) parsePrimaryExpression (--> DEEP) Especially parseTypeId is expensive in this case and it's called two times, both from the same token (index). With this patch, we remember for certain ASTs the parse results and re-use them when needed. Change-Id: I013d1c064c655636bc94db408097863b5e183fc2 Task-number: QTCREATORBUG-12252 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/libs/3rdparty/cplusplus/Parser.h')
-rw-r--r--src/libs/3rdparty/cplusplus/Parser.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libs/3rdparty/cplusplus/Parser.h b/src/libs/3rdparty/cplusplus/Parser.h
index 87007c8f75..4a2a6dfb7e 100644
--- a/src/libs/3rdparty/cplusplus/Parser.h
+++ b/src/libs/3rdparty/cplusplus/Parser.h
@@ -325,6 +325,10 @@ private:
MemoryPool _expressionStatementTempPool;
std::map<unsigned, TemplateArgumentListEntry> _templateArgumentList;
+ class ASTCache;
+ ASTCache *_astCache;
+ ASTCache *_expressionStatementAstCache;
+
private:
Parser(const Parser& source);
void operator =(const Parser& source);