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/qqmlcontext_p.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/qml/qml/qqmlcontext_p.h') diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h index f0e0ab26c6..ddf7d5de75 100644 --- a/src/qml/qml/qqmlcontext_p.h +++ b/src/qml/qml/qqmlcontext_p.h @@ -144,8 +144,17 @@ public: // Compilation unit for contexts that belong to a compiled type. QQmlRefPointer typeCompilationUnit; - // Property name cache - QV4::IdentifierHash propertyNames; + struct ObjectIdMapping { + ObjectIdMapping() : id(-1) {} + ObjectIdMapping(const QString &name, int id) + : name(name), id(id) {} + QString name; + int id; + }; + + mutable QVector idObjectNames; + mutable QV4::IdentifierHash propertyNameCache; + QV4::IdentifierHash &propertyNames() const; // Context object QObject *contextObject; @@ -188,13 +197,6 @@ public: QFlagPointer context; QQmlNotifier bindings; }; - struct ObjectIdMapping { - ObjectIdMapping() : id(-1) {} - ObjectIdMapping(const QString &name, int id) - : name(name), id(id) {} - QString name; - int id; - }; ContextGuard *idValues; int idValueCount; void setIdProperty(int, QObject *); -- cgit v1.2.3