diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-05-02 09:45:29 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-05-02 17:16:07 +0200 |
commit | f961f5e221420ea0b7d32d77167c7ef8e9b9b81a (patch) | |
tree | 0d071f234dad077f61b798e551d4702a2db10f06 /src/qml | |
parent | f6fb9252c6af824ee4544b34a039c20872c5b4ed (diff) |
Use new rvalue overload of QMetaProperty::writeOnGadget()
The new overload avoids the unconditional deep copy inside
QMetaProperty::write()'s lvalue overload.
Task-number: QTBUG-112762
Change-Id: Ic224faf72288e73bb6ad9049f1e0dc585e04ca19
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/qml/qqmlglobal.cpp | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmlvaluetype_p.h | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmlvaluetypewrapper.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlvmemetaobject.cpp | 2 |
4 files changed, 10 insertions, 5 deletions
diff --git a/src/qml/qml/qqmlglobal.cpp b/src/qml/qml/qqmlglobal.cpp index 9bc8142edc..529affcb2a 100644 --- a/src/qml/qml/qqmlglobal.cpp +++ b/src/qml/qml/qqmlglobal.cpp @@ -212,20 +212,20 @@ static void doWriteProperties(const QMetaObject *mo, const QV4::Value &s, void * const QMetaType propertyType = metaProperty.metaType(); QVariant property = QV4::ExecutionEngine::toVariant(v4PropValue, propertyType); if (property.metaType() == propertyType) { - metaProperty.writeOnGadget(target, property); + metaProperty.writeOnGadget(target, std::move(property)); continue; } QVariant converted = QQmlValueTypeProvider::createValueType(v4PropValue, propertyType); if (converted.isValid()) { - metaProperty.writeOnGadget(target, converted); + metaProperty.writeOnGadget(target, std::move(converted)); continue; } converted = QVariant(propertyType); if (QMetaType::convert(property.metaType(), property.constData(), propertyType, converted.data())) { - metaProperty.writeOnGadget(target, converted); + metaProperty.writeOnGadget(target, std::move(converted)); continue; } diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h index fe063fd365..ff82e11003 100644 --- a/src/qml/qml/qqmlvaluetype_p.h +++ b/src/qml/qml/qqmlvaluetype_p.h @@ -93,6 +93,11 @@ public: property.writeOnGadget(m_gadgetPtr, value); } + void writeOnGadget(const QMetaProperty &property, QVariant &&value) + { + property.writeOnGadget(m_gadgetPtr, std::move(value)); + } + private: const QQmlValueType *valueType() const; void *m_gadgetPtr = nullptr; diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index b20e1c79b7..d203f07e87 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -842,7 +842,7 @@ bool QQmlValueTypeWrapper::virtualPut(Managed *m, PropertyKey id, const Value &v v = v.toInt(); void *gadget = r->d()->gadgetPtr(); - property.writeOnGadget(gadget, v); + property.writeOnGadget(gadget, std::move(v)); if (heapObject) r->d()->writeBack(pd.coreIndex()); diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index b8383b8679..c625d2fa20 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -340,7 +340,7 @@ bool QQmlInterceptorMetaObject::doIntercept(QMetaObject::Call c, int id, void ** // change the value soon. Such an animation needs to be canceled if the // current value is explicitly set. // So, we cannot return here if prevComponentValue == newComponentValue. - valueType->writeOnGadget(valueProp, prevComponentValue); + valueType->writeOnGadget(valueProp, std::move(prevComponentValue)); valueType->write(object, id, QQmlPropertyData::DontRemoveBinding | QQmlPropertyData::BypassInterceptor); vi->write(newComponentValue); |