Skip to content
  • Nikolai Kosjar's avatar
    C++: Fix expensive parsing of expressions · d3c5fff6
    Nikolai Kosjar authored
    
    
    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: default avatarErik Verbruggen <erik.verbruggen@digia.com>
    d3c5fff6