diff options
author | Lars Knoll <lars.knoll@qt.io> | 2019-01-03 16:02:09 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2019-02-08 21:55:10 +0000 |
commit | a5a859e721e7a1d0c5a3ec6abe2db55d9144bb36 (patch) | |
tree | 76d2daecce20da784ee12b56d71175e83cf49d18 /src/corelib/kernel/qobject_p.h | |
parent | 88a2a746b7ed49f4ac4861bbf8e3a55db691fa43 (diff) |
Get rid of the connectedSignals bitflags
Measurements show that it's just almost as fast to simply query
the connectionlist directly and avoid both the memory
overhead of the bitfield and the associated bookkeeping.
For connected signals, the difference is not relevant at all.
With a signal that was never connected, removing the bitfield will
cause signal emission to be ~2.5% faster. And if you ever disconnect
from a signal, the bitfields might not be accurate and this can
cause a major slowdown.
Here are some numbers to validate this. All times are measured
in ms for 100M signal emissions:
without change with change
string based connect: 3817 3836
pointer based connect: 4552 4571
not connected: 493 479
disconnected: 2113 559
Change-Id: Ia2c85036afaa7f991b883c8ff812f69cf4580f7e
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/corelib/kernel/qobject_p.h')
-rw-r--r-- | src/corelib/kernel/qobject_p.h | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index a762e6f529..7cc82d4f71 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -201,7 +201,7 @@ public: static const QObjectPrivate *get(const QObject *o) { return o->d_func(); } int signalIndex(const char *signalName, const QMetaObject **meta = nullptr) const; - inline bool isSignalConnected(uint signalIdx, bool checkDeclarative = true) const; + bool isSignalConnected(uint signalIdx, bool checkDeclarative = true) const; inline bool isDeclarativeSignalConnected(uint signalIdx) const; // To allow abitrary objects to call connectNotify()/disconnectNotify() without making @@ -232,7 +232,6 @@ public: Connection *senders; // linked list of connections connected to this object Sender *currentSender; // object currently activating the object - mutable quint32 connectedSignals[2]; union { QObject *currentChildBeingDeleted; // should only be used when QObjectData::isDeletingChildren is set @@ -246,21 +245,6 @@ public: Q_DECLARE_TYPEINFO(QObjectPrivate::ConnectionList, Q_MOVABLE_TYPE); -/*! \internal - - Returns \c true if the signal with index \a signal_index from object \a sender is connected. - Signals with indices above a certain range are always considered connected (see connectedSignals - in QObjectPrivate). - - \a signal_index must be the index returned by QObjectPrivate::signalIndex; -*/ -inline bool QObjectPrivate::isSignalConnected(uint signal_index, bool checkDeclarative) const -{ - return signal_index >= sizeof(connectedSignals) * 8 - || (connectedSignals[signal_index >> 5] & (1 << (signal_index & 0x1f)) - || (checkDeclarative && isDeclarativeSignalConnected(signal_index))); -} - inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const { return declarativeData && QAbstractDeclarativeData::isSignalConnected |