diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-04-10 10:13:04 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-04-21 06:36:53 +0000 |
commit | 50bd7d4720eb7d17545734e79a3cef0f42986a06 (patch) | |
tree | d70863d76ecb0b08a8310fd8410c695118545524 /src/qml/qml/qqmlobjectcreator.cpp | |
parent | 3db3c38b1055cc8b41a9aa951c33f5621babb5d0 (diff) |
Speed up instantiation of objects that are assigned to list properties
For example massive amount of Item{} objects that are "children" of another
item and thus get assigned to the default data list property. Instead of
repeatedly retrieving that list property via a meta-call, we can do that only
once and re-load if necessary.
Change-Id: Ia7d10b84b3c7dca58d9f0b4b2138bd6f916c128d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator.cpp')
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index f4f42f706b..3d8a6437b8 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -686,6 +686,8 @@ void QQmlObjectCreator::setupBindings(const QBitArray &bindingsToSkip) const QV4::CompiledData::BindingPropertyData &propertyData = compiledData->compilationUnit->bindingPropertyDataPerObject.at(_compiledObjectIndex); + int currentListPropertyIndex = -1; + const QV4::CompiledData::Binding *binding = _compiledObject->bindingTable(); for (quint32 i = 0; i < _compiledObject->nBindings; ++i, ++binding) { if (static_cast<int>(i) < bindingsToSkip.size() && bindingsToSkip.testBit(i)) @@ -694,10 +696,15 @@ void QQmlObjectCreator::setupBindings(const QBitArray &bindingsToSkip) const QQmlPropertyData *property = propertyData.at(i); if (property && property->isQList()) { - void *argv[1] = { (void*)&_currentList }; - QMetaObject::metacall(_qobject, QMetaObject::ReadProperty, property->coreIndex, argv); - } else if (_currentList.object) + if (property->coreIndex != currentListPropertyIndex) { + void *argv[1] = { (void*)&_currentList }; + QMetaObject::metacall(_qobject, QMetaObject::ReadProperty, property->coreIndex, argv); + currentListPropertyIndex = property->coreIndex; + } + } else if (_currentList.object) { _currentList = QQmlListProperty<void>(); + currentListPropertyIndex = -1; + } if (!setPropertyBinding(property, binding)) return; |