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>
This commit is contained in:
parent
d18026b007
commit
0dfd0a1c09
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue