diff options
author | Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> | 2023-08-29 15:25:49 +0200 |
---|---|---|
committer | Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> | 2023-09-11 00:32:40 +0200 |
commit | 588700dbfa1ca6c10ab9bc615bd10d065dfb4b72 (patch) | |
tree | 86fe680b2795fbb9a910885ff18058c1c41ead12 /src/dbus/qdbusintegrator.cpp | |
parent | 9aaeb1bb3dc2b24b3dce0cf9943c0bfa2ab191cf (diff) |
QDBusSlotCache: Include flags into the hash key
This removes the need for doing two separate iteration to find
entries in the hash. Also QMultyHash can now be replaced by
plain QHash.
Change-Id: Ie704e74c1dbb0c8e40d22a7cd572fcc8a3bfcd5d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus/qdbusintegrator.cpp')
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 5cef94216b..ed5d424ae4 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -857,19 +857,15 @@ bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBu cacheKey += signature; } - QDBusSlotCache::Hash::ConstIterator cacheIt = slotCache.hash.constFind(cacheKey); - while (cacheIt != slotCache.hash.constEnd() && cacheIt->flags != flags && - cacheIt.key() == cacheKey) - ++cacheIt; - if (cacheIt == slotCache.hash.constEnd() || cacheIt.key() != cacheKey) - { + QDBusSlotCache::Key compoundKey{ std::move(cacheKey), flags }; + QDBusSlotCache::Hash::ConstIterator cacheIt = slotCache.hash.constFind(compoundKey); + if (cacheIt == slotCache.hash.constEnd()) { // not cached, analyze the meta object const QMetaObject *mo = object->metaObject(); QByteArray memberName = msg.member().toUtf8(); // find a slot that matches according to the rules above QDBusSlotCache::Data slotData; - slotData.flags = flags; slotData.slotIdx = ::findSlot(mo, memberName, flags, msg.signature(), slotData.metaTypes); if (slotData.slotIdx == -1) { // ### this is where we want to add the connection as an arg too @@ -881,7 +877,7 @@ bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBu // save the negative lookup slotData.slotIdx = -1; slotData.metaTypes.clear(); - slotCache.hash.insert(cacheKey, slotData); + slotCache.hash.insert(compoundKey, slotData); object->setProperty(cachePropertyName, QVariant::fromValue(slotCache)); qCWarning(dbusIntegration).nospace() << "Could not find slot " << mo->className() @@ -891,7 +887,7 @@ bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBu } // save to the cache - slotCache.hash.insert(cacheKey, slotData); + slotCache.hash.insert(compoundKey, slotData); object->setProperty(cachePropertyName, QVariant::fromValue(slotCache)); // found the slot to be called |