From 95892bd7b20a881c9a50791d9c1a9309f2f01d28 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 17 Jan 2018 15:54:02 +0100 Subject: Allow for currentQmlContext to be inlined Change-Id: Ic2a98a3a4b4362036222df05a92c0bed633c1d1c Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlobjectcreator_p.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/qml/qml/qqmlobjectcreator_p.h') diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index 4536b2e1af..82fe22af72 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -123,7 +123,8 @@ private: void registerObjectWithContextById(const QV4::CompiledData::Object *object, QObject *instance) const; - QV4::Heap::QmlContext *currentQmlContext(); + inline QV4::Heap::QmlContext *currentQmlContext(); + Q_NEVER_INLINE void createQmlContext(); enum Phase { Startup, @@ -173,6 +174,14 @@ private: QRecursionWatcher watcher; }; +QV4::Heap::QmlContext *QQmlObjectCreator::currentQmlContext() +{ + if (Q_UNLIKELY(!_qmlContext->isManaged())) + createQmlContext(); // less common slow path + + return _qmlContext->d(); +} + QT_END_NAMESPACE #endif // QQMLOBJECTCREATOR_P_H -- cgit v1.2.3