summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-09-14 02:35:20 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-09-16 13:35:56 +0000
commit7a0a5edcc747bdef71f11638a8c3c47fb31f8be6 (patch)
tree50f97c613097a084abffa7880fd252c5b0b74071 /src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
parentff59294c0d7a7464870a7a7d3bc1449c7a7695a7 (diff)
[Bluetooth] Optimize loops
Decrease complexity from O(N+N*logN) to just O(N) for cases like foreach (Key key, map.keys()) Value value = map.value(key); , by rewriting with use of iterators. Change-Id: I81f1334797f16b624293fcebdee885b2be3c89f1 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp')
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
index de12e6f2..ae51d681 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
@@ -652,14 +652,18 @@ void QBluetoothServiceDiscoveryAgentPrivate::performMinimalServiceDiscovery(cons
}
QStringList uuidStrings;
- foreach (const QDBusObjectPath &path, reply.value().keys()) {
- const InterfaceList ifaceList = reply.value().value(path);
- foreach (const QString &iface, ifaceList.keys()) {
+
+ ManagedObjectList managedObjectList = reply.value();
+ for (ManagedObjectList::const_iterator it = managedObjectList.constBegin(); it != managedObjectList.constEnd(); ++it) {
+ const InterfaceList &ifaceList = it.value();
+
+ for (InterfaceList::const_iterator jt = ifaceList.constBegin(); jt != ifaceList.constEnd(); ++jt) {
+ const QString &iface = jt.key();
+ const QVariantMap &ifaceValues = jt.value();
+
if (iface == QStringLiteral("org.bluez.Device1")) {
- const QVariantMap details = ifaceList.value(iface);
- if (deviceAddress.toString()
- == details.value(QStringLiteral("Address")).toString()) {
- uuidStrings = details.value(QStringLiteral("UUIDs")).toStringList();
+ if (deviceAddress.toString() == ifaceValues.value(QStringLiteral("Address")).toString()) {
+ uuidStrings = ifaceValues.value(QStringLiteral("UUIDs")).toStringList();
break;
}
}