aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmldata_p.h
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2015-01-29 14:56:00 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-27 10:44:27 +0000
commit0699f27c9da6629ca02a1920146cb32999401676 (patch)
tree222f7691041b311744bbf05431e6fbffbbcaf5ea /src/qml/qml/qqmldata_p.h
parent8018c4b6e7743c576a3548f6e73e588f19f632a9 (diff)
Only heap allocate binding bits storage if needed.
For samegame, this has the following change on the total bytes allocated: Startup (main page): Before: 1636 After: 1072 Difference: 564 bytes (-34%) Actual game (single player): Before: 14120 After: 10432 Difference: 3688 bytes (-26%) Done-with: Robin Burchell <robin.burchell@viroteck.net> Change-Id: I10fd1e9f1440dcff93aed06e2c77c2912bc7dd39 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com> (cherry picked from commit 54a19db8d00b67044861c8ffd1d5b1e646658609) Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmldata_p.h')
-rw-r--r--src/qml/qml/qqmldata_p.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h
index c9bae8e774..c7654be545 100644
--- a/src/qml/qml/qqmldata_p.h
+++ b/src/qml/qml/qqmldata_p.h
@@ -123,8 +123,14 @@ public:
quint32 parentFrozen:1;
quint32 dummy:22;
+ // When bindingBitsSize < 32, we store the binding bit flags inside
+ // bindingBitsValue. When we need more than 32 bits, we allocated
+ // sufficient space and use bindingBits to point to it.
int bindingBitsSize;
- quint32 *bindingBits;
+ union {
+ quint32 *bindingBits;
+ quint32 bindingBitsValue;
+ };
struct NotifyList {
quint64 connectionMask;
@@ -261,19 +267,19 @@ QQmlNotifierEndpoint *QQmlData::notify(int index)
bool QQmlData::hasBindingBit(int coreIndex) const
{
int bit = coreIndex * 2;
- if (bindingBitsSize > bit)
- return bindingBits[bit / 32] & (1 << (bit % 32));
- else
- return false;
+
+ return bindingBitsSize > bit &&
+ ((bindingBitsSize == 32) ? (bindingBitsValue & (1 << bit)) :
+ (bindingBits[bit / 32] & (1 << (bit % 32))));
}
bool QQmlData::hasPendingBindingBit(int coreIndex) const
{
int bit = coreIndex * 2 + 1;
- if (bindingBitsSize > bit)
- return bindingBits[bit / 32] & (1 << (bit % 32));
- else
- return false;
+
+ return bindingBitsSize > bit &&
+ ((bindingBitsSize == 32) ? (bindingBitsValue & (1 << bit)) :
+ (bindingBits[bit / 32] & (1 << (bit % 32))));
}
void QQmlData::flushPendingBinding(QObject *o, int coreIndex)