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 <marc.mutz@qt.io> (cherry picked from commit 43f66e619176e4903aa62a30dc5ae2122e22f13a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
db5e112419
commit
53497c0a01
@ -78,7 +78,7 @@ struct JNITypeForArgImpl
|
||||
using Type = std::conditional_t<std::disjunction_v<std::is_base_of<QJniObject, Arg>,
|
||||
std::is_base_of<QtJniTypes::JObjectBase, Arg>>,
|
||||
jobject, typename PromotedType<Arg>::Type>;
|
||||
static Arg fromVarArg(Type &&t)
|
||||
static Arg fromVarArg(Type t)
|
||||
{
|
||||
return static_cast<Arg>(t);
|
||||
}
|
||||
@ -89,7 +89,7 @@ struct JNITypeForArgImpl<QString>
|
||||
{
|
||||
using Type = jstring;
|
||||
|
||||
static QString fromVarArg(Type &&t)
|
||||
static QString fromVarArg(Type t)
|
||||
{
|
||||
return QJniObject(t).toString();
|
||||
}
|
||||
@ -98,9 +98,9 @@ struct JNITypeForArgImpl<QString>
|
||||
template <typename Arg>
|
||||
using JNITypeForArg = typename JNITypeForArgImpl<std::decay_t<Arg>>::Type;
|
||||
template <typename Arg, typename Type>
|
||||
static inline auto methodArgFromVarArg(Type &&t)
|
||||
static inline auto methodArgFromVarArg(Type t) // Type comes from a va_arg, so is always POD
|
||||
{
|
||||
return JNITypeForArgImpl<std::decay_t<Arg>>::fromVarArg(std::move(t));
|
||||
return JNITypeForArgImpl<std::decay_t<Arg>>::fromVarArg(t);
|
||||
}
|
||||
|
||||
// Turn a va_list into a tuple of typed arguments
|
||||
|
Loading…
x
Reference in New Issue
Block a user