From 53497c0a01526b9bf1d7c883c423a2914696b25e Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 31 Jan 2024 13:44:23 +0100 Subject: [PATCH] JNI: pass POD parameters by value All calls to the fromVarArg() conversion helper are made with JNI types from a va_arg list, so they have to be either primitive types, or a pointer (jobject, which internally is a _jobject *). There's no benefit from moving those or passing them by reference; the most efficient convention is to pass them by value. Change-Id: I6fed9b202be3c6a265117684fecd51d03ccbb534 Reviewed-by: Marc Mutz (cherry picked from commit 43f66e619176e4903aa62a30dc5ae2122e22f13a) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/kernel/qjnitypes.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qjnitypes.h b/src/corelib/kernel/qjnitypes.h index 71c4db670ce..978b0f0e8fb 100644 --- a/src/corelib/kernel/qjnitypes.h +++ b/src/corelib/kernel/qjnitypes.h @@ -78,7 +78,7 @@ struct JNITypeForArgImpl using Type = std::conditional_t, std::is_base_of>, jobject, typename PromotedType::Type>; - static Arg fromVarArg(Type &&t) + static Arg fromVarArg(Type t) { return static_cast(t); } @@ -89,7 +89,7 @@ struct JNITypeForArgImpl { using Type = jstring; - static QString fromVarArg(Type &&t) + static QString fromVarArg(Type t) { return QJniObject(t).toString(); } @@ -98,9 +98,9 @@ struct JNITypeForArgImpl template using JNITypeForArg = typename JNITypeForArgImpl>::Type; template -static inline auto methodArgFromVarArg(Type &&t) +static inline auto methodArgFromVarArg(Type t) // Type comes from a va_arg, so is always POD { - return JNITypeForArgImpl>::fromVarArg(std::move(t)); + return JNITypeForArgImpl>::fromVarArg(t); } // Turn a va_list into a tuple of typed arguments