From 0cc4772bf90af07064d451d7284548dd11694994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Brooke?= Date: Sat, 26 Jul 2025 09:22:36 +0200 Subject: QQueuedMetaCallEvent: use sized-free to dealloc args_ We are only one multiplication by 16 (PtrAndTypeSize) away from the allocSize, so compute it to speed up the deallocation for compatible allocators such as jemalloc. Amends b7d073e9905bf9812ba96cecdcf6871a95517d30. Change-Id: I959e5db308381bb8012511b37c99d93f486d66e7 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/corelib/kernel/qobject.cpp') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 980fefc4eae..aa429636bd3 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -622,7 +622,7 @@ QQueuedMetaCallEvent::~QQueuedMetaCallEvent() } if (d.nargs_) { if (static_cast(d.args_) != prealloc_) - free(d.args_); + QtPrivate::sizedFree(d.args_, d.nargs_, PtrAndTypeSize); } } @@ -634,9 +634,8 @@ inline void QQueuedMetaCallEvent::allocArgs() if (!d.nargs_) return; - constexpr size_t each = sizeof(void*) + sizeof(QMetaType); - void *const memory = d.nargs_ * each > sizeof(prealloc_) ? - calloc(d.nargs_, each) : prealloc_; + void *const memory = d.nargs_ * PtrAndTypeSize > sizeof(prealloc_) ? + calloc(d.nargs_, PtrAndTypeSize) : prealloc_; Q_CHECK_PTR(memory); d.args_ = static_cast(memory); -- cgit v1.2.3