From 496ddbfd1fe27bdddf5c15cd0ea70df452a3ec04 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 10 Apr 2015 14:56:24 +0200 Subject: Speed up object creation with lots of id name objects In the common case when objects are referenced by id, we don't need the QQmlContextData's property name cache for the lookup. Instead of bindings we resolve the id to an integer at type compilation time. Therefore we can delay the population of the QQmlContextData's propertyNames until we need it and therefore safe time on startup. Change-Id: I2e8eeb51b1ac92f230059be3467f9a1e00fdbbef Reviewed-by: Lars Knoll --- src/qml/qml/qqmlcontextwrapper.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/qml/qml/qqmlcontextwrapper.cpp') diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index 2498e5acc9..7aca9ad6c2 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -199,8 +199,9 @@ ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty while (context) { // Search context properties - if (context->propertyNames.count()) { - int propertyIdx = context->propertyNames.value(name); + const QV4::IdentifierHash &properties = context->propertyNames(); + if (properties.count()) { + int propertyIdx = properties.value(name); if (propertyIdx != -1) { @@ -308,8 +309,9 @@ void QmlContextWrapper::put(Managed *m, String *name, const Value &value) QObject *scopeObject = wrapper->getScopeObject(); while (context) { + const QV4::IdentifierHash &properties = context->propertyNames(); // Search context properties - if (context->propertyNames.count() && -1 != context->propertyNames.value(name)) + if (properties.count() && properties.value(name) != -1) return; // Search scope object -- cgit v1.2.3