summaryrefslogtreecommitdiffstats
path: root/src/core/qpostman.cpp
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2015-01-12 18:43:34 +0100
committerSean Harmer <sean.harmer@kdab.com>2015-01-13 13:25:57 +0100
commit25548027a3cc498a88dfdebe9f4f6d868e765fbf (patch)
tree78facff645a5aee48ddc6e551cb3d16fa721f6a9 /src/core/qpostman.cpp
parent6197e529d67218d64551f855a64fdb4958eb47a9 (diff)
Optimize: Do not repeat method lookup on every scene change event.
Instead, cache the QMetaMethod lookup once and invoke it directly in all subsequent calls to QPostMan::sceneChangeEvent. Profiling showed me that QMetaObject::indexOfMethod took up ca. 8% of the total CPU time. This hotspot is now removed. Change-Id: Id36d824900cc892fc98e5bd32880bfe6aae47341 Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/core/qpostman.cpp')
-rw-r--r--src/core/qpostman.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/core/qpostman.cpp b/src/core/qpostman.cpp
index 027a372a3..8f6201669 100644
--- a/src/core/qpostman.cpp
+++ b/src/core/qpostman.cpp
@@ -77,11 +77,17 @@ void QPostman::setScene(QSceneInterface *scene)
d->m_scene = scene;
}
+static inline QMetaMethod notifyFrontendNodeMethod()
+{
+ int idx = QPostman::staticMetaObject.indexOfMethod("notifyFrontendNode(QSceneChangePtr)");
+ Q_ASSERT(idx != -1);
+ return QPostman::staticMetaObject.method(idx);
+}
+
void QPostman::sceneChangeEvent(const QSceneChangePtr &e)
{
- QMetaObject::invokeMethod(this,
- "notifyFrontendNode",
- Q_ARG(QSceneChangePtr, e));
+ static const QMetaMethod notifyFrontendNode = notifyFrontendNodeMethod();
+ notifyFrontendNode.invoke(this, Q_ARG(QSceneChangePtr, e));
}
void QPostman::notifyFrontendNode(QSceneChangePtr e)