summaryrefslogtreecommitdiff
path: root/src/plugins/geoservices/nokia
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-01-14 16:19:41 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-01-15 11:28:51 +0000
commitfad740822e13225f9cd9d567a346b4f2b7d6f65a (patch)
tree63cb777b9f671ed56f130a3bae67ddd9d591bbaa /src/plugins/geoservices/nokia
parenta756c0a88b43c4b7251d6b2b95acddbe3af26932 (diff)
downloadqtlocation-fad740822e13225f9cd9d567a346b4f2b7d6f65a.tar.gz
fix expensive iteration over QMap::keys(), QHash::keys()
... and QJsonObject::keys() Change-Id: I9a8ba44406a1e2cbdfffd266d2b5cb664f7440fc Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/plugins/geoservices/nokia')
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp5
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp7
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp12
3 files changed, 12 insertions, 12 deletions
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp
index 40bec231..e85b9cc7 100644
--- a/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp
@@ -269,14 +269,15 @@ void QPlaceDetailsReplyImpl::replyFinished()
if (object.contains(QLatin1String("extended"))) {
QJsonObject extendedObject = object.value(QLatin1String("extended")).toObject();
- foreach (const QString &key, extendedObject.keys()) {
- QJsonObject attributeObject = extendedObject.value(key).toObject();
+ for (auto it = extendedObject.constBegin(), end = extendedObject.constEnd(); it != end; ++it) {
+ QJsonObject attributeObject = it.value().toObject();
QPlaceAttribute attribute;
attribute.setLabel(attributeObject.value(QLatin1String("label")).toString());
attribute.setText(attributeObject.value(QLatin1String("text")).toString());
+ QString key = it.key();
if (key == QLatin1String("payment"))
place.setExtendedAttribute(QPlaceAttribute::Payment, attribute);
else if (key == QLatin1String("openingHours"))
diff --git a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
index 0713ba10..4f44e5fd 100644
--- a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
@@ -194,13 +194,12 @@ void QGeoTiledMappingManagerEngineNokia::loadCopyrightsDescriptorsFromJson(const
}
QJsonObject jsonObj = doc.object();
- QStringList keys = jsonObj.keys();
m_copyrights.clear();
- for (int keyIndex = 0; keyIndex < keys.count(); keyIndex++) {
+ for (auto it = jsonObj.constBegin(), end = jsonObj.constEnd(); it != end; ++it) {
QList<CopyrightDesc> copyrightDescList;
- QJsonArray descs = jsonObj[ keys[ keyIndex ] ].toArray();
+ QJsonArray descs = it.value().toArray();
for (int descIndex = 0; descIndex < descs.count(); descIndex++) {
CopyrightDesc copyrightDesc;
QJsonObject desc = descs.at(descIndex).toObject();
@@ -225,7 +224,7 @@ void QGeoTiledMappingManagerEngineNokia::loadCopyrightsDescriptorsFromJson(const
}
copyrightDescList << copyrightDesc;
}
- m_copyrights[ keys[ keyIndex ] ] = copyrightDescList;
+ m_copyrights[it.key()] = copyrightDescList;
}
}
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
index ac20c262..6dcb28da 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
@@ -627,18 +627,18 @@ QPlaceReply *QPlaceManagerEngineNokiaV2::initializeCategories()
}
//request all categories in the tree from the server
- //because we don't want the root node, we remove it from the list
- QStringList ids = m_tempTree.keys();
- ids.removeAll(QString());
- foreach (const QString &id, ids) {
+ //because we don't want the root node, we skip it
+ for (auto it = m_tempTree.keyBegin(), end = m_tempTree.keyEnd(); it != end; ++it) {
+ if (*it == QString())
+ continue;
QUrl requestUrl(QString::fromLatin1("http://") + m_uriProvider->getCurrentHost() +
- QStringLiteral("/places/v1/categories/places/") + id);
+ QStringLiteral("/places/v1/categories/places/") + *it);
QNetworkReply *networkReply = sendRequest(requestUrl);
connect(networkReply, SIGNAL(finished()), this, SLOT(categoryReplyFinished()));
connect(networkReply, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(categoryReplyError()));
- m_categoryRequests.insert(id, networkReply);
+ m_categoryRequests.insert(*it, networkReply);
}
QPlaceCategoriesReplyHere *reply = new QPlaceCategoriesReplyHere(this);