summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2013-12-19 17:21:32 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-27 15:51:02 +0100
commit110890e091cd1f112b18196048f62efe7b858e19 (patch)
tree25522ee80249349e400ad9a34b696743556940dd /src
parent25568c9d01e5ace5557c9aebc42d0de3cf2873e4 (diff)
downloadqtwebchannel-110890e091cd1f112b18196048f62efe7b858e19.tar.gz
Cleanup and optimize code a bit by calling senderSignalIndex less.
Profiling shows that sender() and senderSignalIndex(), which again calls sender() internally, are the hotspots in benchPropertyUpdates. To speed things up a bit, call senderSignalIndex only once whenever a signal is emitted. The performance gain is about 27% (16ms vs. 22ms). While at it, also re-use the global s_destroyedSignalIndex static and also call sender() only once even when assertions are enabled. Change-Id: I90cd1a2b453e5c40d0f41276968f4545b42076bc Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/webchannel/signalhandler_p.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/webchannel/signalhandler_p.h b/src/webchannel/signalhandler_p.h
index 5bc1f4d..7360028 100644
--- a/src/webchannel/signalhandler_p.h
+++ b/src/webchannel/signalhandler_p.h
@@ -245,12 +245,16 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
if (call == QMetaObject::InvokeMetaMethod) {
if (methodId == 0) {
- Q_ASSERT(sender());
- Q_ASSERT(senderSignalIndex() != -1);
- dispatch(sender(), senderSignalIndex(), args);
- static const int destroyedIndex = metaObject()->indexOfSignal("destroyed(QObject*)");
- if (senderSignalIndex() == destroyedIndex) {
- ConnectionHash::iterator it = m_connectionsCounter.find(sender());
+ const QObject *object = sender();
+ Q_ASSERT(object);
+ const int signalIndex = senderSignalIndex();
+ Q_ASSERT(signalIndex != -1);
+
+ dispatch(object, signalIndex, args);
+
+ if (signalIndex == s_destroyedSignalIndex) {
+ // disconnect on QObject::destroyed
+ ConnectionHash::iterator it = m_connectionsCounter.find(object);
Q_ASSERT(it != m_connectionsCounter.end());
foreach (const ConnectionPair &connection, *it) {
QObject::disconnect(connection.first);