From 50bd7d4720eb7d17545734e79a3cef0f42986a06 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 10 Apr 2015 10:13:04 +0200 Subject: 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 --- src/qml/qml/qqmlobjectcreator.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/qml/qml') 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(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(); + currentListPropertyIndex = -1; + } if (!setPropertyBinding(property, binding)) return; -- cgit v1.2.3