use union in PrimaryExpressionAST to reduce memory footprint

Review Request #104127 - Created March 1, 2012 and submitted

Milian Wolff
On 64bit sizeof(PrimaryExpressionAST) == 64, but with this patch it reduces to 40 by using a union + enum.

The code-handling is a bit changed, but well... is this OK to land in master?

This is another step towards a reduced memory consumption for the test file in with this patch the consumption goes down by ~200mb for the given test file
all unit tests pass


Milian Wolff
Aleix Pol Gonzalez
Aleix Pol Gonzalez
Milian Wolff
Review request changed

Status: Closed (submitted)

Change Summary:

commit 7310ea61043390d5e31f1d07d5bb35f0b06ad4e7
Author: Milian Wolff <>
Date:   Sat Nov 24 21:16:29 2012 +0100

    Use union in PrimaryExpressionAST to reduce memory footprint.
    On 64Bit machines, we had sizeof(PrimaryExpressionAST) == 64.
    By using a union and enum this can be decreased to 40.
    This can result in dramatically less memory consumption, esp. for
    large qrc files e.g. In the case of the file attached to bug 291248
    the memory consumption dropped by 200MB.
    While the code handling is now a bit changed, I still think this
    change is worth it. While at it, I've also refactored
    ExpressionVisitor::visitPrimaryExpression. This gives us cleaner code
    and should also be faster since we can use the token type instead of
    doing string comparisons to find numbers.
    CCBUG: 291248