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/qbluetoothserviceinfo_osx.mm | |
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/qbluetoothserviceinfo_osx.mm')
-rw-r--r-- | src/bluetooth/qbluetoothserviceinfo_osx.mm | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/bluetooth/qbluetoothserviceinfo_osx.mm b/src/bluetooth/qbluetoothserviceinfo_osx.mm index 755e85c9..27da70fc 100644 --- a/src/bluetooth/qbluetoothserviceinfo_osx.mm +++ b/src/bluetooth/qbluetoothserviceinfo_osx.mm @@ -359,12 +359,12 @@ static void dumpAttributeVariant(const QVariant &var, const QString indent) } else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Sequence>()) { qDebug("%sSequence", indent.toLocal8Bit().constData()); const QBluetoothServiceInfo::Sequence *sequence = static_cast<const QBluetoothServiceInfo::Sequence *>(var.data()); - foreach (const QVariant &v, *sequence) + for (const QVariant &v : *sequence) dumpAttributeVariant(v, indent + QLatin1Char('\t')); } else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Alternative>()) { qDebug("%sAlternative", indent.toLocal8Bit().constData()); const QBluetoothServiceInfo::Alternative *alternative = static_cast<const QBluetoothServiceInfo::Alternative *>(var.data()); - foreach (const QVariant &v, *alternative) + for (const QVariant &v : *alternative) dumpAttributeVariant(v, indent + QLatin1Char('\t')); } break; @@ -375,7 +375,8 @@ static void dumpAttributeVariant(const QVariant &var, const QString indent) QDebug operator << (QDebug dbg, const QBluetoothServiceInfo &info) { - foreach (quint16 id, info.attributes()) { + const QList<quint16> attributes = info.attributes(); + for (quint16 id : attributes) { dumpAttributeVariant(info.attribute(id), QString::fromLatin1("(%1)\t").arg(id)); } return dbg; @@ -386,7 +387,9 @@ QBluetoothServiceInfo::Sequence QBluetoothServiceInfoPrivate::protocolDescriptor if (!attributes.contains(QBluetoothServiceInfo::ProtocolDescriptorList)) return QBluetoothServiceInfo::Sequence(); - foreach (const QVariant &v, attributes.value(QBluetoothServiceInfo::ProtocolDescriptorList).value<QBluetoothServiceInfo::Sequence>()) { + const QBluetoothServiceInfo::Sequence sequence + = attributes.value(QBluetoothServiceInfo::ProtocolDescriptorList).value<QBluetoothServiceInfo::Sequence>(); + for (const QVariant &v : sequence) { QBluetoothServiceInfo::Sequence parameters = v.value<QBluetoothServiceInfo::Sequence>(); if (parameters.empty()) continue; |