summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-05-04 15:48:12 +0200
committerMarc Mutz <marc.mutz@qt.io>2023-05-05 13:53:44 +0200
commitb6d5d419cce1134a2e71723e4323ecfa2e70f13c (patch)
tree15f4ea2af5b314cf8e3b0c99d32d328906ec18d9 /src
parent3c4743c66cca4137510e090659b0400700754ec4 (diff)
QObject: simplify ImplFns of Q(Private)SlotObjects
Drag the cast out of each case to before the switch. DRYs the code. Pick-to: 6.5 Change-Id: I117cc5d38379a11e9852fba61794fa59dc24a30f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qobject_p.h7
-rw-r--r--src/corelib/kernel/qobjectdefs_impl.h9
2 files changed, 9 insertions, 7 deletions
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index d56e9aa60ca..ef89786a4d3 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -290,16 +290,17 @@ class QPrivateSlotObject : public QSlotObjectBase, private FunctionStorage<Func>
typedef QtPrivate::FunctionPointer<Func> FuncType;
static void impl(int which, QSlotObjectBase *this_, QObject *r, void **a, bool *ret)
{
+ const auto that = static_cast<QPrivateSlotObject*>(this_);
switch (which) {
case Destroy:
- delete static_cast<QPrivateSlotObject*>(this_);
+ delete that;
break;
case Call:
- FuncType::template call<Args, R>(static_cast<QPrivateSlotObject*>(this_)->func(),
+ FuncType::template call<Args, R>(that->func(),
static_cast<typename FuncType::Object *>(QObjectPrivate::get(r)), a);
break;
case Compare:
- *ret = *reinterpret_cast<Func *>(a) == static_cast<QPrivateSlotObject*>(this_)->func();
+ *ret = *reinterpret_cast<Func *>(a) == that->func();
break;
case NumOperations: ;
}
diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h
index 41ef92b4aa4..156a6d6c42d 100644
--- a/src/corelib/kernel/qobjectdefs_impl.h
+++ b/src/corelib/kernel/qobjectdefs_impl.h
@@ -413,19 +413,20 @@ namespace QtPrivate {
FunctorValue function;
static void impl(int which, QSlotObjectBase *this_, QObject *r, void **a, bool *ret)
{
+ const auto that = static_cast<QFunctorSlotObject*>(this_);
switch (which) {
case Destroy:
- delete static_cast<QFunctorSlotObject*>(this_);
+ delete that;
break;
case Call:
if constexpr (std::is_member_function_pointer_v<FunctorValue>)
- FuncType::template call<Args, R>(static_cast<QFunctorSlotObject*>(this_)->function, static_cast<typename FuncType::Object *>(r), a);
+ FuncType::template call<Args, R>(that->function, static_cast<typename FuncType::Object *>(r), a);
else
- FuncType::template call<Args, R>(static_cast<QFunctorSlotObject*>(this_)->function, r, a);
+ FuncType::template call<Args, R>(that->function, r, a);
break;
case Compare:
if constexpr (std::is_member_function_pointer_v<FunctorValue>) {
- *ret = *reinterpret_cast<FunctorValue *>(a) == static_cast<QFunctorSlotObject*>(this_)->function;
+ *ret = *reinterpret_cast<FunctorValue *>(a) == that->function;
break;
}
// not implemented otherwise