aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/types/qqmllistmodel.cpp
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-01-15 15:31:00 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-01-18 07:53:43 +0000
commitf4d1a471bb87dd4d4bb79b10e8dc434d707711bd (patch)
treec7ac9009009a293abb88bdf95533c39fca714128 /src/qml/types/qqmllistmodel.cpp
parent9e980750c6647ffcf2cb95e95e63fa8335924866 (diff)
Qml: fix expensive iteration over QHash::keys() and QMap::keys()
Change-Id: I7bb5dd3b49b9f3a638f81156a02d999dbbd932f3 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/qml/types/qqmllistmodel.cpp')
-rw-r--r--src/qml/types/qqmllistmodel.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index a4c0f7043f..28462006a6 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -1399,13 +1399,8 @@ void DynamicRoleModelNode::sync(DynamicRoleModelNode *src, DynamicRoleModelNode
void DynamicRoleModelNode::updateValues(const QVariantMap &object, QVector<int> &roles)
{
- const QList<QString> &keys = object.keys();
-
- QList<QString>::const_iterator it = keys.begin();
- QList<QString>::const_iterator end = keys.end();
-
- while (it != end) {
- const QString &key = *it;
+ for (auto it = object.cbegin(), end = object.cend(); it != end; ++it) {
+ const QString &key = it.key();
int roleIndex = m_owner->m_roles.indexOf(key);
if (roleIndex == -1) {
@@ -1413,7 +1408,7 @@ void DynamicRoleModelNode::updateValues(const QVariantMap &object, QVector<int>
m_owner->m_roles.append(key);
}
- QVariant value = object[key];
+ QVariant value = it.value();
// A JS array/object is translated into a (hierarchical) QQmlListModel,
// so translate to a variant map/list first with toVariant().
@@ -1444,8 +1439,6 @@ void DynamicRoleModelNode::updateValues(const QVariantMap &object, QVector<int>
if (m_meta->setValue(keyUtf8, value))
roles << roleIndex;
-
- ++it;
}
}