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;
|
typedef QtPrivate::FunctionPointer<Func> FuncType;
|
||||||
static void impl(int which, QSlotObjectBase *this_, QObject *r, void **a, bool *ret)
|
static void impl(int which, QSlotObjectBase *this_, QObject *r, void **a, bool *ret)
|
||||||
{
|
{
|
||||||
|
const auto that = static_cast<QPrivateSlotObject*>(this_);
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case Destroy:
|
case Destroy:
|
||||||
delete static_cast<QPrivateSlotObject*>(this_);
|
delete that;
|
||||||
break;
|
break;
|
||||||
case Call:
|
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);
|
static_cast<typename FuncType::Object *>(QObjectPrivate::get(r)), a);
|
||||||
break;
|
break;
|
||||||
case Compare:
|
case Compare:
|
||||||
*ret = *reinterpret_cast<Func *>(a) == static_cast<QPrivateSlotObject*>(this_)->func();
|
*ret = *reinterpret_cast<Func *>(a) == that->func();
|
||||||
break;
|
break;
|
||||||
case NumOperations: ;
|
case NumOperations: ;
|
||||||
}
|
}
|
||||||
|
@ -413,19 +413,20 @@ namespace QtPrivate {
|
|||||||
FunctorValue function;
|
FunctorValue function;
|
||||||
static void impl(int which, QSlotObjectBase *this_, QObject *r, void **a, bool *ret)
|
static void impl(int which, QSlotObjectBase *this_, QObject *r, void **a, bool *ret)
|
||||||
{
|
{
|
||||||
|
const auto that = static_cast<QFunctorSlotObject*>(this_);
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case Destroy:
|
case Destroy:
|
||||||
delete static_cast<QFunctorSlotObject*>(this_);
|
delete that;
|
||||||
break;
|
break;
|
||||||
case Call:
|
case Call:
|
||||||
if constexpr (std::is_member_function_pointer_v<FunctorValue>)
|
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
|
else
|
||||||
FuncType::template call<Args, R>(static_cast<QFunctorSlotObject*>(this_)->function, r, a);
|
FuncType::template call<Args, R>(that->function, r, a);
|
||||||
break;
|
break;
|
||||||
case Compare:
|
case Compare:
|
||||||
if constexpr (std::is_member_function_pointer_v<FunctorValue>) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
// not implemented otherwise
|
// not implemented otherwise
|
||||||
|
Loading…
Reference in New Issue
Block a user