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>
This commit is contained in:
parent
3c4743c66c
commit
b6d5d419cc
@ -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: ;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user