aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlcontext.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2016-05-25 10:25:25 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-05-26 11:33:00 +0000
commit8457ca1b3dfb048acdb4426960ad7ee7c8227ed4 (patch)
treed33256028f22b5a28a9ea6fda3b98bedc5aeebab /src/qml/qml/qqmlcontext.cpp
parent899c1ef0f7574019f1b41a922b2ba10614df130f (diff)
Simplify object to id-in-context mapping
By storing the calculated integer id for an id-named object in CompiledData::Object we can simplify the code and replace a hash table with a plain vector. Change-Id: I4a84cdd00e98766d603d152e5a6574b232771a02 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/qml/qml/qqmlcontext.cpp')
-rw-r--r--src/qml/qml/qqmlcontext.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp
index af06405376..11a8e81d8f 100644
--- a/src/qml/qml/qqmlcontext.cpp
+++ b/src/qml/qml/qqmlcontext.cpp
@@ -760,12 +760,12 @@ void QQmlContextData::setIdProperty(int idx, QObject *obj)
idValues[idx].context = this;
}
-void QQmlContextData::setIdPropertyData(const QHash<int, int> &data)
+void QQmlContextData::setNamedObjects(const QVector<quint32> &objects)
{
- Q_ASSERT(objectIndexToId.isEmpty());
- objectIndexToId = data;
+ Q_ASSERT(namedObjects.isEmpty());
+ namedObjects = objects;
Q_ASSERT(propertyNameCache.isEmpty());
- idValueCount = data.count();
+ idValueCount = objects.count();
idValues = new ContextGuard[idValueCount];
}
@@ -808,13 +808,12 @@ QV4::IdentifierHash<int> &QQmlContextData::propertyNames() const
{
if (propertyNameCache.isEmpty()) {
propertyNameCache = QV4::IdentifierHash<int>(QV8Engine::getV4(engine->handle()));
- for (QHash<int, int>::ConstIterator it = objectIndexToId.cbegin(), end = objectIndexToId.cend();
- it != end; ++it) {
- const QV4::CompiledData::Object *obj = typeCompilationUnit->data->objectAt(it.key());
- const QString name = typeCompilationUnit->data->stringAt(obj->idIndex);
- propertyNameCache.add(name, it.value());
+ for (int i = 0; i < namedObjects.count(); ++i) {
+ const QV4::CompiledData::Object *obj = typeCompilationUnit->data->objectAt(namedObjects.at(i));
+ const QString name = typeCompilationUnit->data->stringAt(obj->idNameIndex);
+ propertyNameCache.add(name, obj->id);
}
- objectIndexToId.clear();
+ namedObjects.clear();
}
return propertyNameCache;
}