From a0ade068004ad869d6235ae8d6cd5e2050bf765d Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 14 Aug 2018 11:08:18 +0200 Subject: Replace foreach with for loop and set QT_NO_FOREACH To avoid unnecessary copies, const is used wherever possible. Change-Id: Ic743716512751cfd24fad5bd37c244b115dd26fe Reviewed-by: Qt CI Bot Reviewed-by: Alex Blasche --- src/bluetooth/bluez/bluez5_helper.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/bluetooth/bluez') diff --git a/src/bluetooth/bluez/bluez5_helper.cpp b/src/bluetooth/bluez/bluez5_helper.cpp index f798088e..2beb533c 100644 --- a/src/bluetooth/bluez/bluez5_helper.cpp +++ b/src/bluetooth/bluez/bluez5_helper.cpp @@ -331,7 +331,8 @@ QtBluezDiscoveryManager::~QtBluezDiscoveryManager() { qCDebug(QT_BT_BLUEZ) << "Destroying QtBluezDiscoveryManager"; - foreach (const QString &adapterPath, d->references.keys()) { + const QList adapterPaths = d->references.keys(); + for (const QString &adapterPath : adapterPaths) { AdapterData *data = d->references.take(adapterPath); delete data->propteryListener; @@ -416,7 +417,8 @@ void QtBluezDiscoveryManager::unregisterDiscoveryInterest(const QString &adapter // if (d->references.isEmpty()) { // qCDebug(QT_BT_BLUEZ) << "No running registration"; // } else { -// foreach (const QString &path, d->references.keys()) { +// const QList paths = d->references.keys(); +// for (const QString &path : paths) { // qCDebug(QT_BT_BLUEZ) << path << "->" << d->references[path]->reference; // } // } @@ -536,7 +538,7 @@ QString findAdapterForAddress(const QBluetoothAddress &wantedAddress, bool *ok = if (wantedAddress.isNull()) return localAdapters.front().first; // -> return first found adapter - foreach (const AddressForPathType &pair, localAdapters) { + for (const AddressForPathType &pair : qAsConst(localAdapters)) { if (pair.second == wantedAddress) return pair.first; // -> found local adapter with wanted address } -- cgit v1.2.3