diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-05-25 14:55:44 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-05-26 19:57:55 +0000 |
commit | e850416fcffe48cc19cdbf6a01f759964815681c (patch) | |
tree | 87afa793953710a74c530900ab7cbf93fd6cb3cb /src/qml/qml/qqmlcontext_p.h | |
parent | 6f84a09dfbd15aac023580cf06e7b8c24f3b524c (diff) |
Optimize named object handling
By storing the object indices of named objects in the CompiledData::Object of a component,
we can achieve two things:
(1) We can eliminate the hash of vectors in QQmlCompiledData for the object-to-id mapping
(2) We can store the mapping from object name to integer object id in the CompilationUnit and
share it across different QQmlContextData instances (as long as it is not modified).
Also added a new test that verifies the functionality of a .qml file starting
with Component{} itself with object names, something that was previously only
implicitly tested through some of the examples (corkboards.qml for example).
Change-Id: I28c70217222dc0e5252bf5247b7e3fc4def47446
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/qml/qml/qqmlcontext_p.h')
-rw-r--r-- | src/qml/qml/qqmlcontext_p.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h index e455c1f07b..05ce39401e 100644 --- a/src/qml/qml/qqmlcontext_p.h +++ b/src/qml/qml/qqmlcontext_p.h @@ -151,9 +151,15 @@ public: // Compilation unit for contexts that belong to a compiled type. QQmlRefPointer<QV4::CompiledData::CompilationUnit> typeCompilationUnit; - mutable QVector<quint32> namedObjects; + // object index in CompiledData::Unit to component that created this context + int componentObjectIndex; + + void initFromTypeCompilationUnit(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit, int subComponentIndex); + + // flag indicates whether the context owns the cache (after mutation) or not. mutable QV4::IdentifierHash<int> propertyNameCache; - QV4::IdentifierHash<int> &propertyNames() const; + const QV4::IdentifierHash<int> &propertyNames() const; + QV4::IdentifierHash<int> &detachedPropertyNames(); // Context object QObject *contextObject; @@ -201,7 +207,6 @@ public: ContextGuard *idValues; int idValueCount; void setIdProperty(int, QObject *); - void setNamedObjects(const QVector<quint32> &objects); // Linked contexts. this owns linkedContext. QQmlContextData *linkedContext; |