diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-04-10 15:17:51 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-04-16 17:14:25 +0000 |
commit | 33aa21ab0430ae71f5ee44459e250091c09d56b1 (patch) | |
tree | 944b25bfb0b9eb76c549bd054584f03be706dddc /src/qml/qml/qqmlcontext.cpp | |
parent | 61f218b4e772c1d97e32ef8031de0043473ebbef (diff) |
Speed up composite type instantiation with lots of IDs
We don't need to convert from a QHash to a QVector in order to populate the
property name cache in QQmlContextData.
Change-Id: Ifa8e4f64a1e174907e92684b2d38abaf0a4a705c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlcontext.cpp')
-rw-r--r-- | src/qml/qml/qqmlcontext.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index 3e6ca6667e..f08f650913 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -760,10 +760,10 @@ void QQmlContextData::setIdProperty(int idx, QObject *obj) idValues[idx].context = this; } -void QQmlContextData::setIdPropertyData(const QVector<ObjectIdMapping> &data) +void QQmlContextData::setIdPropertyData(const QHash<int, int> &data) { - Q_ASSERT(idObjectNames.isEmpty()); - idObjectNames = data; + Q_ASSERT(objectIndexToId.isEmpty()); + objectIndexToId = data; Q_ASSERT(propertyNameCache.isEmpty()); idValueCount = data.count(); idValues = new ContextGuard[idValueCount]; @@ -808,10 +808,13 @@ QV4::IdentifierHash<int> &QQmlContextData::propertyNames() const { if (propertyNameCache.isEmpty()) { propertyNameCache = QV4::IdentifierHash<int>(QV8Engine::getV4(engine->handle())); - for (QVector<ObjectIdMapping>::ConstIterator it = idObjectNames.begin(), end = idObjectNames.end(); - it != end; ++it) - propertyNameCache.add(it->name, it->id); - idObjectNames.clear(); + for (QHash<int, int>::ConstIterator it = objectIndexToId.begin(), end = objectIndexToId.end(); + 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()); + } + objectIndexToId.clear(); } return propertyNameCache; } |