aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickpropertychanges.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2016-04-08 15:20:23 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-06-27 06:20:23 +0000
commit3dfd47362fea05bc354f814b5b743856f5ce7462 (patch)
treef8f1088995b9ffa121defafd6a976c19bbc34a55 /src/quick/util/qquickpropertychanges.cpp
parentd453275a883b6af4e8c7c45dcc632c3728221047 (diff)
QML: Specialize bindings based on target property type.
When we can determine the type of a target property during type compilation, we can skip a whole bunch of code that deals with converting the result of a binding to the correct (target) type. This removes 65 instructions on x86 for such typed bindings. Change-Id: Id2c7c57b9ae6dfbeb921121beae9630604ca1d17 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/quick/util/qquickpropertychanges.cpp')
-rw-r--r--src/quick/util/qquickpropertychanges.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp
index df65e0822b..a42ec31058 100644
--- a/src/quick/util/qquickpropertychanges.cpp
+++ b/src/quick/util/qquickpropertychanges.cpp
@@ -456,11 +456,13 @@ QQuickPropertyChanges::ActionList QQuickPropertyChanges::actions()
if (e.id != QQmlBinding::Invalid) {
QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this)));
QV4::ScopedValue function(scope, QV4::FunctionObject::createQmlFunction(context, object(), d->compilationUnit->runtimeFunctions[e.id]));
- newBinding = new QQmlBinding(function, object(), context);
+ newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core,
+ function, object(), context);
}
// QQmlBinding *newBinding = e.id != QQmlBinding::Invalid ? QQmlBinding::createBinding(e.id, object(), qmlContext(this)) : 0;
if (!newBinding)
- newBinding = new QQmlBinding(e.expression, object(), context, e.url.toString(), e.line, e.column);
+ newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core,
+ e.expression, object(), context, e.url.toString(), e.line, e.column);
if (d->isExplicit) {
// in this case, we don't want to assign a binding, per se,
@@ -624,8 +626,11 @@ void QQuickPropertyChanges::changeExpression(const QString &name, const QString
if (entry.name == name) {
entry.expression = expression;
if (state() && state()->isStateActive()) {
- QQmlBinding *newBinding = new QQmlBinding(expression, object(), qmlContext(this));
- newBinding->setTarget(d->property(name));
+ auto prop = d->property(name);
+ QQmlBinding *newBinding = QQmlBinding::create(
+ &QQmlPropertyPrivate::get(prop)->core, expression, object(),
+ qmlContext(this));
+ newBinding->setTarget(prop);
QQmlPropertyPrivate::setBinding(newBinding, QQmlPropertyPrivate::None, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor);
}
return;
@@ -643,8 +648,11 @@ void QQuickPropertyChanges::changeExpression(const QString &name, const QString
state()->changeBindingInRevertList(object(), name, oldBinding);
}
- QQmlBinding *newBinding = new QQmlBinding(expression, object(), qmlContext(this));
- newBinding->setTarget(d->property(name));
+ auto prop = d->property(name);
+ QQmlBinding *newBinding = QQmlBinding::create(
+ &QQmlPropertyPrivate::get(prop)->core, expression, object(),
+ qmlContext(this));
+ newBinding->setTarget(prop);
QQmlPropertyPrivate::setBinding(newBinding, QQmlPropertyPrivate::None, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor);
} else {
QQuickStateAction action;
@@ -654,7 +662,9 @@ void QQuickPropertyChanges::changeExpression(const QString &name, const QString
action.specifiedObject = object();
action.specifiedProperty = name;
- QQmlBinding *newBinding = new QQmlBinding(expression, object(), qmlContext(this));
+ QQmlBinding *newBinding = QQmlBinding::create(
+ &QQmlPropertyPrivate::get(action.property)->core, expression,
+ object(), qmlContext(this));
if (d->isExplicit) {
// don't assign the binding, merely evaluate the expression.
// XXX TODO: add a static QQmlJavaScriptExpression::evaluate(QString)