aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlvmemetaobject.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-03-24 18:01:16 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-03-29 09:04:13 +0100
commitb82ae347397595241dcd4a5848ad0c6bfae4574b (patch)
tree045bea2be5ac6c88ccf498537913e200a4e627d6 /src/qml/qml/qqmlvmemetaobject.cpp
parentbd294e78239a198c9c7458a490681d170823a97f (diff)
Avoid needless construction and destruction of return values
In most cases the AOT compiled function will successfully placement-new the return value. Therefore, we can provide uninitialized space. Only do the construct/destruct dance in the cases when it's already slow. Change-Id: Ia339774fde03e459f290f167ddadd1c47a644b8e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlvmemetaobject.cpp')
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index 7580d45104..7e6e4b1ef3 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -1002,10 +1002,14 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
if (arguments && arguments->names) {
const auto parameterCount = arguments->names->count();
Q_ASSERT(parameterCount == function->formalParameterCount());
+ if (void *result = a[0])
+ arguments->types[0].destruct(result);
function->call(v4->globalObject, a, arguments->types, parameterCount);
} else {
Q_ASSERT(function->formalParameterCount() == 0);
const QMetaType returnType = methodData->propType();
+ if (void *result = a[0])
+ returnType.destruct(result);
function->call(v4->globalObject, a, &returnType, 0);
}