diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-06-16 13:29:36 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-06-17 07:38:52 +0000 |
commit | 0dfd0a1c09e36bb80c575c097ea6a5809df5e640 (patch) | |
tree | 6f75455308411941b8cb499dcb224c846af7cec4 /src/qml | |
parent | d18026b00713de93bc3bd8f7e85f1ff0cf128185 (diff) |
Move object/binding counter code to CompilationUnit
The code to update the counters operates entirely on data structures
from CompilationUnit, so it makes sense to move it into that class.
Plus - you guessed it - this will also be called when not using the type
compiler in the future.
Change-Id: I644b0914980b799be1020ed74d2791b127bbcf9f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/compiler/qqmltypecompiler.cpp | 25 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 28 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 2 |
3 files changed, 31 insertions, 24 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index add330d5ce..766e1fd40f 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -218,30 +218,7 @@ QV4::CompiledData::CompilationUnit *QQmlTypeCompiler::compile() } } - // Collect some data for instantiation later. - int bindingCount = 0; - int parserStatusCount = 0; - int objectCount = 0; - for (quint32 i = 0; i < qmlUnit->nObjects; ++i) { - const QV4::CompiledData::Object *obj = qmlUnit->objectAt(i); - bindingCount += obj->nBindings; - if (auto *typeRef = resolvedTypes.value(obj->inheritedTypeNameIndex)) { - if (QQmlType *qmlType = typeRef->type) { - if (qmlType->parserStatusCast() != -1) - ++parserStatusCount; - } - ++objectCount; - if (typeRef->compilationUnit) { - bindingCount += typeRef->compilationUnit->totalBindingsCount; - parserStatusCount += typeRef->compilationUnit->totalParserStatusCount; - objectCount += typeRef->compilationUnit->totalObjectCount; - } - } - } - - compilationUnit->totalBindingsCount = bindingCount; - compilationUnit->totalParserStatusCount = parserStatusCount; - compilationUnit->totalObjectCount = objectCount; + compilationUnit->updateBindingAndObjectCounters(); if (errors.isEmpty()) return compilationUnit; diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index db25e265d0..a97902e2a0 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -238,6 +238,34 @@ IdentifierHash<int> CompilationUnit::namedObjectsPerComponent(int componentObjec return *it; } +void CompilationUnit::updateBindingAndObjectCounters() +{ + + // Collect some data for instantiation later. + int bindingCount = 0; + int parserStatusCount = 0; + int objectCount = 0; + for (quint32 i = 0; i < data->nObjects; ++i) { + const QV4::CompiledData::Object *obj = data->objectAt(i); + bindingCount += obj->nBindings; + if (auto *typeRef = resolvedTypes.value(obj->inheritedTypeNameIndex)) { + if (QQmlType *qmlType = typeRef->type) { + if (qmlType->parserStatusCast() != -1) + ++parserStatusCount; + } + ++objectCount; + if (typeRef->compilationUnit) { + bindingCount += typeRef->compilationUnit->totalBindingsCount; + parserStatusCount += typeRef->compilationUnit->totalParserStatusCount; + objectCount += typeRef->compilationUnit->totalObjectCount; + } + } + } + + totalBindingsCount = bindingCount; + totalParserStatusCount = parserStatusCount; + totalObjectCount = objectCount; +} #endif // V4_BOOTSTRAP Unit *CompilationUnit::createUnitData(QmlIR::Document *irDocument) diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 36103a7b37..10bc01e883 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -760,6 +760,8 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnit : public QQmlRefCount QHash<int, IdentifierHash<int>> namedObjectsPerComponentCache; IdentifierHash<int> namedObjectsPerComponent(int componentObjectIndex); + void updateBindingAndObjectCounters(); + int totalBindingsCount; // Number of bindings used in this type int totalParserStatusCount; // Number of instantiated types that are QQmlParserStatus subclasses int totalObjectCount; // Number of objects explicitly instantiated |