diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-10-14 12:06:23 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-10-18 13:31:48 +0000 |
commit | 06e3cfb0c49ca94d4456d7abc8b332ef9582ae62 (patch) | |
tree | a97f0931750cf78d16ad3b1c62517d294e65bfbe /src/qml/qml/qqmldata_p.h | |
parent | 2c2c92d999ae8584840e44785fbece9bf2cfac62 (diff) |
QML: Split two QQmlData methods into fast/slow paths
The common case is that the property cache and the QQmlData itself are
already created. By splitting the creation off into a slow-path method,
these simple methods are cheap to inline.
Change-Id: I73c702b5e66f35379647946a0c431561fd87499b
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 | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index dce75c51aa..e271598c2d 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -207,8 +207,7 @@ public: } else if (priv->declarativeData) { return static_cast<QQmlData *>(priv->declarativeData); } else if (create) { - priv->declarativeData = new QQmlData; - return static_cast<QQmlData *>(priv->declarativeData); + return createQQmlData(priv); } else { return 0; } @@ -231,12 +230,22 @@ public: static inline void flushPendingBinding(QObject *, QQmlPropertyIndex propertyIndex); - static QQmlPropertyCache *ensurePropertyCache(QJSEngine *engine, QObject *object); + static QQmlPropertyCache *ensurePropertyCache(QJSEngine *engine, QObject *object) + { + Q_ASSERT(engine); + QQmlData *ddata = QQmlData::get(object, /*create*/true); + if (Q_LIKELY(ddata->propertyCache)) + return ddata->propertyCache; + return createPropertyCache(engine, object); + } private: // For attachedProperties mutable QQmlDataExtended *extendedData; + Q_NEVER_INLINE static QQmlData *createQQmlData(QObjectPrivate *priv); + Q_NEVER_INLINE static QQmlPropertyCache *createPropertyCache(QJSEngine *engine, QObject *object); + void flushPendingBindingImpl(QQmlPropertyIndex index); Q_ALWAYS_INLINE bool hasBitSet(int bit) const |