aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlobjectcreator.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-08 15:55:34 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-14 13:07:51 +0000
commit062bcba3901e03268306f9ae77df1dae271a6ad1 (patch)
tree7159803750003d98fb35f1f059de4bab5174c2e2 /src/qml/qml/qqmlobjectcreator.cpp
parente600b04282e964f64f9db7795cef15da32a51b21 (diff)
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 <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator.cpp')
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp3
1 files changed, 1 insertions, 2 deletions
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;