aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2016-10-14 12:06:23 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2016-10-18 13:31:48 +0000
commit06e3cfb0c49ca94d4456d7abc8b332ef9582ae62 (patch)
treea97f0931750cf78d16ad3b1c62517d294e65bfbe /src/qml/qml
parent2c2c92d999ae8584840e44785fbece9bf2cfac62 (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')
-rw-r--r--src/qml/qml/qqmldata_p.h15
-rw-r--r--src/qml/qml/qqmlengine.cpp18
2 files changed, 23 insertions, 10 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
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index c10aa0129c..7877ee7e21 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -1861,15 +1861,19 @@ void QQmlData::setPendingBindingBit(QObject *obj, int coreIndex)
QQmlData_setBit(this, obj, coreIndex * 2 + 1);
}
-QQmlPropertyCache *QQmlData::ensurePropertyCache(QJSEngine *engine, QObject *object)
+QQmlData *QQmlData::createQQmlData(QObjectPrivate *priv)
+{
+ Q_ASSERT(priv);
+ priv->declarativeData = new QQmlData;
+ return static_cast<QQmlData *>(priv->declarativeData);
+}
+
+QQmlPropertyCache *QQmlData::createPropertyCache(QJSEngine *engine, QObject *object)
{
- Q_ASSERT(engine);
QQmlData *ddata = QQmlData::get(object, /*create*/true);
- if (!ddata->propertyCache) {
- ddata->propertyCache = QJSEnginePrivate::get(engine)->cache(object);
- if (ddata->propertyCache)
- ddata->propertyCache->addref();
- }
+ ddata->propertyCache = QJSEnginePrivate::get(engine)->cache(object);
+ if (ddata->propertyCache)
+ ddata->propertyCache->addref();
return ddata->propertyCache;
}