diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-09-01 15:17:27 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-09-02 12:46:41 +0000 |
commit | ed9f8a0e9d2984b0b9d6aa31ab3a7209bae1708e (patch) | |
tree | c0f7b12c7a5e2a0f78823eb53bbd7391280a061a /src/plugins/bearer/linux_common/qofonoservice_linux.cpp | |
parent | 73331eebf885ba8918447d26ba37bef2208bdb5e (diff) |
bearer plugins: eradicate Java-style iterators and Q_FOREACH
This is the simple part of the job, removing Q_FOREACH loops
which are obviously safe to be replaced by C++11 range-for.
In QNetworkManagerEngine::sessionStateForId(), instead of
iterating over QHash::keys(), iterate over the QHash
directly (using C++11 range-for, as we're only using the
values, not the keys).
In QNetworkManagerEngine::connectToId(), simplify the loop
body by merging three identical if blocks into one.
Saves ~1.7KiB accumulated over the three Linux bearer plugins:
connman, generic, nm (optimized GCC 6.1 Linux AMD64 build).
Change-Id: Ic66139c25f7e2173f5a919927e269b873334d2c8
Reviewed-by: Lorn Potter <lorn.potter@canonical.com>
Diffstat (limited to 'src/plugins/bearer/linux_common/qofonoservice_linux.cpp')
-rw-r--r-- | src/plugins/bearer/linux_common/qofonoservice_linux.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp b/src/plugins/bearer/linux_common/qofonoservice_linux.cpp index b0f5f29f6c..adf7feef2e 100644 --- a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp +++ b/src/plugins/bearer/linux_common/qofonoservice_linux.cpp @@ -103,9 +103,9 @@ QStringList QOfonoManagerInterface::getModems() QDBusPendingReply<PathPropertiesList> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetModems"), argumentList); reply.waitForFinished(); if (!reply.isError()) { - foreach (const ObjectPathProperties &modem, reply.value()) { + const auto modems = reply.value(); + for (const ObjectPathProperties &modem : modems) modemList << modem.path.path(); - } } } @@ -114,8 +114,8 @@ QStringList QOfonoManagerInterface::getModems() QString QOfonoManagerInterface::currentModem() { - QStringList modems = getModems(); - foreach (const QString &modem, modems) { + const QStringList modems = getModems(); + for (const QString &modem : modems) { QOfonoModemInterface device(modem); if (device.isPowered() && device.isOnline() && device.interfaces().contains(QStringLiteral("org.ofono.NetworkRegistration"))) @@ -266,9 +266,9 @@ QStringList QOfonoDataConnectionManagerInterface::contexts() QDBusPendingReply<PathPropertiesList > reply = call(QLatin1String("GetContexts")); reply.waitForFinished(); if (!reply.isError()) { - foreach (const ObjectPathProperties &context, reply.value()) { + const auto contexts = reply.value(); + for (const ObjectPathProperties &context : contexts) contextList << context.path.path(); - } } } return contextList; |