From 062bcba3901e03268306f9ae77df1dae271a6ad1 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 8 Apr 2015 15:55:34 +0200 Subject: Simple speed-up for binding setup during object instantiation We use stringAt() to retrieve the name of the id property of an object but all we do with that string is check if it has a length. So if an id is set, we allocate memory and copy the string data into a new QString, and if it's not set then we get a default constructed QString. Either way the string isn't used and we can simply check for whether the id is set by checking if the idIndex is non-zero. Change-Id: Ib84fb05ed31c59f7e85dac72ab61b4d3bc9c902b Reviewed-by: Lars Knoll --- src/qml/qml/qqmlobjectcreator.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/qml/qml/qqmlobjectcreator.cpp') diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 29995e828d..a32dc9e0a9 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -656,8 +656,7 @@ void QQmlObjectCreator::setupBindings(const QBitArray &bindingsToSkip) QQmlPropertyData *defaultProperty = _compiledObject->indexOfDefaultProperty != -1 ? _propertyCache->parent()->defaultProperty() : _propertyCache->defaultProperty(); - QString id = stringAt(_compiledObject->idIndex); - if (!id.isEmpty()) { + if (_compiledObject->idIndex) { QQmlPropertyData *idProperty = _propertyCache->property(QStringLiteral("id"), _qobject, context); if (idProperty && idProperty->isWritable() && idProperty->propType == QMetaType::QString) { QV4::CompiledData::Binding idBinding; -- cgit v1.2.3