diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2011-03-16 00:23:06 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2011-03-16 02:51:46 (GMT) |
commit | 99512251be8e5814238ec398854a8aa71fa8b25d (patch) | |
tree | cdaba27de02a9aadc1b61ab8dd3ea36b25e58a7d /src/declarative/qml/qdeclarativeobjectscriptclass.cpp | |
parent | 82ae515e52e3811d3b2aec588e0dd777350c1c33 (diff) | |
download | Qt-99512251be8e5814238ec398854a8aa71fa8b25d.zip Qt-99512251be8e5814238ec398854a8aa71fa8b25d.tar.gz Qt-99512251be8e5814238ec398854a8aa71fa8b25d.tar.bz2 |
Optimization and benchmark for setting object properties from QML.
Change-Id: Ib923e5d3946e99001ef682a9dd8ca6d7788818a3
Reviewed-by: Aaron Kennedy
Diffstat (limited to 'src/declarative/qml/qdeclarativeobjectscriptclass.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativeobjectscriptclass.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index dc3ecca..e7ab9cd 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -395,6 +395,33 @@ void QDeclarativeObjectScriptClass::setProperty(QObject *obj, } else if (value.isFunction() && !value.isRegExp()) { // this is handled by the binding creation above } else { + //### expand optimization for other known types + if (lastData->propType == QMetaType::Int && value.isNumber()) { + int rawValue = qRound(value.toNumber()); + int status = -1; + int flags = 0; + void *a[] = { (void *)&rawValue, 0, &status, &flags }; + QMetaObject::metacall(obj, QMetaObject::WriteProperty, + lastData->coreIndex, a); + return; + } else if (lastData->propType == QMetaType::QReal && value.isNumber()) { + qreal rawValue = qreal(value.toNumber()); + int status = -1; + int flags = 0; + void *a[] = { (void *)&rawValue, 0, &status, &flags }; + QMetaObject::metacall(obj, QMetaObject::WriteProperty, + lastData->coreIndex, a); + return; + } else if (lastData->propType == QMetaType::QString && value.isString()) { + const QString &rawValue = value.toString(); + int status = -1; + int flags = 0; + void *a[] = { (void *)&rawValue, 0, &status, &flags }; + QMetaObject::metacall(obj, QMetaObject::WriteProperty, + lastData->coreIndex, a); + return; + } + QVariant v; if (lastData->flags & QDeclarativePropertyCache::Data::IsQList) v = enginePriv->scriptValueToVariant(value, qMetaTypeId<QList<QObject *> >()); |