summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Krause <volker.krause@kdab.com>2016-01-05 16:46:46 +0100
committerVolker Krause <volker.krause@kdab.com>2016-01-05 18:09:02 +0000
commit3fb05bd937b0d8af2ff51fd4e495d4759d9f6bdb (patch)
treea484731f2f671f4b4f32032b8d623d7ab64ff645 /src
parentd7bac6ddfad25c17315e572aa111459054f53c90 (diff)
Avoid frequent method lookups by name.
Name based lookups are fairly expensive, especially since they involve parsing of the method name, which includes allocations. Change-Id: I465d4ddd92764a7e82dc80aa4e697c25e30c00d2 Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/qpostman.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/core/qpostman.cpp b/src/core/qpostman.cpp
index fead32db3..35aa888df 100644
--- a/src/core/qpostman.cpp
+++ b/src/core/qpostman.cpp
@@ -86,6 +86,13 @@ void QPostman::sceneChangeEvent(const QSceneChangePtr &e)
notifyFrontendNode.invoke(this, Q_ARG(QSceneChangePtr, e));
}
+static inline QMetaMethod submitChangeBatchMethod()
+{
+ int idx = QPostman::staticMetaObject.indexOfMethod("submitChangeBatch()");
+ Q_ASSERT(idx != -1);
+ return QPostman::staticMetaObject.method(idx);
+}
+
/*!
* This will start or append \a change to a batch of changes from frontend
* nodes. Once the batch is complete, when the event loop returns, the batch is
@@ -98,8 +105,10 @@ void QPostman::notifyBackend(const QSceneChangePtr &change)
// otherwise start batch
// by calling a queued slot
Q_D(QPostman);
- if (d->m_batch.empty())
- QMetaObject::invokeMethod(this, "submitChangeBatch", Qt::QueuedConnection);
+ if (d->m_batch.empty()) {
+ static const QMetaMethod submitChangeBatch = submitChangeBatchMethod();
+ submitChangeBatch.invoke(this, Qt::QueuedConnection);
+ }
d->m_batch.push_back(change);
}