From ec1248b1831d7ae5d1278caafa258f9c8eb9db09 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 16 Jul 2023 12:10:33 +0200 Subject: [PATCH] QMetaCallEvent::create: extract template-argument-independent code Extract Method create_impl() with all the stuff that doesn't depend on create()'s template arguments, which will reduce compile time and amount of generated code. Change-Id: I9d8f59c168873ac3527b570ef6142079824061cf Reviewed-by: Volker Hilsheimer (cherry picked from commit dc7820a296d58cc61628addd010e28d893d4950b) Reviewed-by: Marc Mutz --- src/corelib/kernel/qobject.cpp | 19 +++++++++++++++++++ src/corelib/kernel/qobject_p.h | 16 ++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 9269e3b6cd..a163c014b5 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -624,6 +624,25 @@ void QMetaCallEvent::placeMetaCall(QObject *object) } } +QMetaCallEvent* QMetaCallEvent::create_impl(QtPrivate::QSlotObjectBase *slotObj, + const QObject *sender, int signal_index, + size_t argc, const void* const argp[], + const QMetaType metaTypes[]) +{ + auto metaCallEvent = std::make_unique(slotObj, sender, + signal_index, int(argc)); + + void **args = metaCallEvent->args(); + QMetaType *types = metaCallEvent->types(); + for (size_t i = 0; i < argc; ++i) { + types[i] = metaTypes[i]; + args[i] = types[i].create(argp[i]); + Q_CHECK_PTR(!i || args[i]); + } + + return metaCallEvent.release(); +} + /*! \class QSignalBlocker \brief Exception-safe wrapper around QObject::blockSignals(). diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 937ac59f8e..ae3744aa71 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -394,18 +394,7 @@ public: const void* const argp[] = { nullptr, std::addressof(argv)... }; const QMetaType metaTypes[] = { QMetaType::fromType(), QMetaType::fromType()... }; constexpr auto argc = sizeof...(Args) + 1; - auto metaCallEvent = std::make_unique(slotObj, sender, - signal_index, int(argc)); - - void **args = metaCallEvent->args(); - QMetaType *types = metaCallEvent->types(); - for (size_t i = 0; i < argc; ++i) { - types[i] = metaTypes[i]; - args[i] = types[i].create(argp[i]); - Q_CHECK_PTR(!i || args[i]); - } - - return metaCallEvent.release(); + return create_impl(slotObj, sender, signal_index, argc, argp, metaTypes); } inline int id() const { return d.method_offset_ + d.method_relative_; } @@ -417,6 +406,9 @@ public: virtual void placeMetaCall(QObject *object) override; private: + static QMetaCallEvent *create_impl(QtPrivate::QSlotObjectBase *slotObj, const QObject *sender, + int signal_index, size_t argc, const void * const argp[], + const QMetaType metaTypes[]); inline void allocArgs(); struct Data {