summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothserviceinfo.cpp
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2018-08-14 11:08:18 +0200
committerOliver Wolff <oliver.wolff@qt.io>2018-08-15 07:56:46 +0000
commita0ade068004ad869d6235ae8d6cd5e2050bf765d (patch)
tree42c949ba2fa7fcd4ab5356293d1ef3cad1c436f6 /src/bluetooth/qbluetoothserviceinfo.cpp
parent84f0e76c647e7f09529b79525b2d4fbc698576d8 (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.cpp')
-rw-r--r--src/bluetooth/qbluetoothserviceinfo.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/bluetooth/qbluetoothserviceinfo.cpp b/src/bluetooth/qbluetoothserviceinfo.cpp
index d706e4a7..d98e616f 100644
--- a/src/bluetooth/qbluetoothserviceinfo.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo.cpp
@@ -606,12 +606,12 @@ static void dumpAttributeVariant(QDebug dbg, const QVariant &var, const QString&
} else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Sequence>()) {
dbg << QString::asprintf("%sSequence\n", indent.toUtf8().constData());
const QBluetoothServiceInfo::Sequence *sequence = static_cast<const QBluetoothServiceInfo::Sequence *>(var.data());
- foreach (const QVariant &v, *sequence)
+ for (const QVariant &v : *sequence)
dumpAttributeVariant(dbg, v, indent + QLatin1Char('\t'));
} else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Alternative>()) {
dbg << QString::asprintf("%sAlternative\n", indent.toUtf8().constData());
const QBluetoothServiceInfo::Alternative *alternative = static_cast<const QBluetoothServiceInfo::Alternative *>(var.data());
- foreach (const QVariant &v, *alternative)
+ for (const QVariant &v : *alternative)
dumpAttributeVariant(dbg, v, indent + QLatin1Char('\t'));
}
break;
@@ -626,7 +626,8 @@ QDebug operator<<(QDebug dbg, const QBluetoothServiceInfo &info)
{
QDebugStateSaver saver(dbg);
dbg.noquote() << "\n";
- foreach (quint16 id, info.attributes()) {
+ QList<quint16> attributes = info.attributes();
+ for (quint16 id : attributes) {
dumpAttributeVariant(dbg, info.attribute(id), QStringLiteral("(%1)\t").arg(id));
}
return dbg;
@@ -637,7 +638,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;