diff options
author | Oliver Wolff <oliver.wolff@qt.io> | 2018-08-14 11:08:18 +0200 |
---|---|---|
committer | Oliver Wolff <oliver.wolff@qt.io> | 2018-08-15 07:56:46 +0000 |
commit | a0ade068004ad869d6235ae8d6cd5e2050bf765d (patch) | |
tree | 42c949ba2fa7fcd4ab5356293d1ef3cad1c436f6 /src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp | |
parent | 84f0e76c647e7f09529b79525b2d4fbc698576d8 (diff) |
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 <qt_ci_bot@qt-project.org>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp')
-rw-r--r-- | src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp index ea9f354b..82939c26 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp @@ -223,7 +223,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::runExternalSdpScan( // No filter implies PUBLIC_BROWSE_GROUP based SDP scan if (!uuidFilter.isEmpty()) { arguments << QLatin1String("-u"); // cmd line option for list of uuids - foreach (const QBluetoothUuid& uuid, uuidFilter) + for (const QBluetoothUuid& uuid : qAsConst(uuidFilter)) arguments << uuid.toString(); } @@ -286,14 +286,16 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD errorString = errorDescription; emit q->error(error); } else if (!xmlRecords.isEmpty() && discoveryState() != Inactive) { - foreach (const QString &record, xmlRecords) { + for (const QString &record : xmlRecords) { const QBluetoothServiceInfo serviceInfo = parseServiceXml(record); //apply uuidFilter if (!uuidFilter.isEmpty()) { bool serviceNameMatched = uuidFilter.contains(serviceInfo.serviceUuid()); bool serviceClassMatched = false; - foreach (const QBluetoothUuid &id, serviceInfo.serviceClassUuids()) { + const QList<QBluetoothUuid> serviceClassUuids + = serviceInfo.serviceClassUuids(); + for (const QBluetoothUuid &id : serviceClassUuids) { if (uuidFilter.contains(id)) { serviceClassMatched = true; break; @@ -519,7 +521,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::discoverServices(const QString &dev _q_serviceDiscoveryFinished(); } else { QString pattern; - foreach (const QBluetoothUuid &uuid, uuidFilter) + for (const QBluetoothUuid &uuid : qAsConst(uuidFilter)) pattern += uuid.toString().remove(QLatin1Char('{')).remove(QLatin1Char('}')) + QLatin1Char(' '); pattern = pattern.trimmed(); @@ -558,13 +560,13 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_discoveredServices(QDBusPendingC return; } - ServiceMap map = reply.value(); + const ServiceMap map = reply.value(); qCDebug(QT_BT_BLUEZ) << "Parsing xml" << discoveredDevices.at(0).address().toString() << discoveredDevices.count() << map.count(); - foreach (const QString &record, reply.value()) { + for (const QString &record : map) { QBluetoothServiceInfo serviceInfo = parseServiceXml(record); if (!serviceInfo.isValid()) @@ -578,7 +580,8 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_discoveredServices(QDBusPendingC // to our own naming resolution. if (serviceInfo.serviceName().isEmpty() && !serviceInfo.serviceClassUuids().isEmpty()) { - foreach (const QBluetoothUuid &classUuid, serviceInfo.serviceClassUuids()) { + const QList<QBluetoothUuid> classUuids = serviceInfo.serviceClassUuids(); + for (const QBluetoothUuid &classUuid : classUuids) { bool ok = false; QBluetoothUuid::ServiceClassUuid clsId = static_cast<QBluetoothUuid::ServiceClassUuid>(classUuid.toUInt16(&ok)); |