summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothdevicediscoveryagent_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/qbluetoothdevicediscoveryagent_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/qbluetoothdevicediscoveryagent_bluez.cpp')
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
index 7f477a02..b0fd88d5 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
@@ -239,9 +239,14 @@ void QBluetoothDeviceDiscoveryAgentPrivate::startBluez5()
QDBusPendingReply<ManagedObjectList> reply = managerBluez5->GetManagedObjects();
reply.waitForFinished();
if (!reply.isError()) {
- 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 QDBusObjectPath &path = it.key();
+ const InterfaceList &ifaceList = it.value();
+
+ for (InterfaceList::const_iterator jt = ifaceList.constBegin(); jt != ifaceList.constEnd(); ++jt) {
+ const QString &iface = jt.key();
+
if (iface == QStringLiteral("org.bluez.Device1")) {
if (path.path().indexOf(adapterBluez5->path()) != 0)