aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2016-05-26 10:28:55 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-05-26 19:58:06 +0000
commit18f96551629346599e0b74c3d093697ef494819a (patch)
treeb7ccf029aa8fd271d54705323528186be0c4f2fa
parente850416fcffe48cc19cdbf6a01f759964815681c (diff)
Simplify id and alias collection
Ids and aliases that refer to their target by id are bound to the scope of components. Instead of determining this boundary through a binary search for bindings that refer to the inner object, we can simply query the flags of the component object itself as to when to stop. This is based on the assumption that a component has only one binding anyway. Change-Id: I9a555ca95f8274b6d9a98793a2c946f47348f9d4 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp15
-rw-r--r--src/qml/compiler/qqmltypecompiler_p.h3
2 files changed, 5 insertions, 13 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp
index f26a38adf0..3e63e4246f 100644
--- a/src/qml/compiler/qqmltypecompiler.cpp
+++ b/src/qml/compiler/qqmltypecompiler.cpp
@@ -1409,7 +1409,6 @@ void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(const QmlI
binding->value.objectIndex = componentIndex;
componentRoots.append(componentIndex);
- componentBoundaries.append(syntheticBinding->value.objectIndex);
}
}
@@ -1464,15 +1463,11 @@ bool QQmlComponentAndAliasResolver::resolve()
// We are going to collect ids/aliases and resolve them for the root object as a separate
// last pass.
- if (i != indexOfRootObject) {
+ if (i != indexOfRootObject)
componentRoots.append(i);
- componentBoundaries.append(rootBinding->value.objectIndex);
- }
}
- std::sort(componentBoundaries.begin(), componentBoundaries.end());
-
for (int i = 0; i < componentRoots.count(); ++i) {
QmlIR::Object *component = qmlObjects->at(componentRoots.at(i));
const QmlIR::Binding *rootBinding = component->firstBinding();
@@ -1530,16 +1525,16 @@ bool QQmlComponentAndAliasResolver::collectIdsAndAliases(int objectIndex)
if (obj->aliasCount() > 0)
_objectsWithAliases.append(objectIndex);
+ // Stop at Component boundary
+ if (obj->flags & QV4::CompiledData::Object::IsComponent && objectIndex != compiler->rootObjectIndex())
+ return true;
+
for (const QmlIR::Binding *binding = obj->firstBinding(); binding; binding = binding->next) {
if (binding->type != QV4::CompiledData::Binding::Type_Object
&& binding->type != QV4::CompiledData::Binding::Type_AttachedProperty
&& binding->type != QV4::CompiledData::Binding::Type_GroupProperty)
continue;
- // Stop at Component boundary
- if (std::binary_search(componentBoundaries.constBegin(), componentBoundaries.constEnd(), binding->value.objectIndex))
- continue;
-
if (!collectIdsAndAliases(binding->value.objectIndex))
return false;
}
diff --git a/src/qml/compiler/qqmltypecompiler_p.h b/src/qml/compiler/qqmltypecompiler_p.h
index 48dffb59c4..2b84bc7ebe 100644
--- a/src/qml/compiler/qqmltypecompiler_p.h
+++ b/src/qml/compiler/qqmltypecompiler_p.h
@@ -273,9 +273,6 @@ protected:
// indices of the objects that are actually Component {}
QVector<int> componentRoots;
- // indices of objects that are the beginning of a new component
- // scope. This is sorted and used for binary search.
- QVector<quint32> componentBoundaries;
int _componentIndex;
QHash<int, int> _idToObjectIndex;