summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothsocket_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/qbluetoothsocket_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/qbluetoothsocket_bluez.cpp')
-rw-r--r--src/bluetooth/qbluetoothsocket_bluez.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp
index 6947e9d0..71f26296 100644
--- a/src/bluetooth/qbluetoothsocket_bluez.cpp
+++ b/src/bluetooth/qbluetoothsocket_bluez.cpp
@@ -384,13 +384,17 @@ QString QBluetoothSocketPrivate::peerName() const
if (reply.isError())
return QString();
- 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")) {
- if (ifaceList.value(iface).value(QStringLiteral("Address")).toString()
- == peerAddress)
- return ifaceList.value(iface).value(QStringLiteral("Alias")).toString();
+ if (ifaceValues.value(QStringLiteral("Address")).toString() == peerAddress)
+ return ifaceValues.value(QStringLiteral("Alias")).toString();
}
}
}