diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-01-16 16:34:03 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-01-17 09:20:18 +0000 |
commit | c2d0693ca99171ebeb8f35423f29562b0d26c6c0 (patch) | |
tree | 602146f52e5250a8ab987a4857619c558e39349c /src/qml/qml/qqmldata_p.h | |
parent | 4e0277664071c31e2189e2351e3e9d12c4e7e08c (diff) |
Have more bindingBits available inline
Many QML items have more than 32 properties, so we ended
up malloc'ing the binding bit table on the heap quite
often. Extending the inline data to be able to accommodate
for up to 64 properties fixes that.
Change-Id: I90a42d601a5406ffacf2506f1957b0c2080bbb7b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmldata_p.h')
-rw-r--r-- | src/qml/qml/qqmldata_p.h | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index 4848f48766..5794e6f0c5 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -156,18 +156,21 @@ public: quint32 hasInterceptorMetaObject:1; quint32 hasVMEMetaObject:1; quint32 parentFrozen:1; - quint32 dummy:22; + quint32 dummy:6; // When bindingBitsSize < sizeof(ptr), we store the binding bit flags inside // bindingBitsValue. When we need more than sizeof(ptr) bits, we allocated // sufficient space and use bindingBits to point to it. - int bindingBitsSize; + quint32 bindingBitsArraySize : 16; typedef quintptr BindingBitsType; + enum { + BitsPerType = sizeof(BindingBitsType) * 8, + InlineBindingArraySize = 2 + }; union { BindingBitsType *bindingBits; - BindingBitsType bindingBitsValue; + BindingBitsType bindingBitsValue[InlineBindingArraySize]; }; - enum { MaxInlineBits = sizeof(BindingBitsType) * 8 }; struct NotifyList { quint64 connectionMask; @@ -275,6 +278,9 @@ public: return createPropertyCache(engine, object); } + Q_ALWAYS_INLINE static uint offsetForBit(int bit) { return static_cast<uint>(bit) / BitsPerType; } + Q_ALWAYS_INLINE static BindingBitsType bitFlagForBit(int bit) { return BindingBitsType(1) << (static_cast<uint>(bit) & (BitsPerType - 1)); } + private: // For attachedProperties mutable QQmlDataExtended *extendedData; @@ -286,13 +292,12 @@ private: Q_ALWAYS_INLINE bool hasBitSet(int bit) const { - if (bindingBitsSize <= bit) + uint offset = offsetForBit(bit); + if (bindingBitsArraySize <= offset) return false; - if (bindingBitsSize == MaxInlineBits) - return bindingBitsValue & (BindingBitsType(1) << bit); - else - return bindingBits[bit / MaxInlineBits] & (BindingBitsType(1) << (bit % MaxInlineBits)); + const BindingBitsType *bits = (bindingBitsArraySize == InlineBindingArraySize) ? bindingBitsValue : bindingBits; + return bits[offset] & bitFlagForBit(bit); } }; |