From 53a842f66bcbb7bba63169a2c9bb974ba0f04585 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 16 May 2022 21:10:44 +0200 Subject: [PATCH] Give some TLC to FlaggedDebugSignatures - add noexcept - use std::array instead of C array - add comment explaining locations.size() Change-Id: Ied6c043e693fecc232878a00ea882c97bda150b6 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index c72b8a761c9..1d96110e257 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2606,17 +2606,15 @@ namespace { // This class provides (per-thread) storage for qFlagLocation() class FlaggedDebugSignatures { - static constexpr uint Count = 2; - uint idx = 0; - const char *locations[Count] = {}; + std::array locations = {}; // one for the SIGNAL, one for the SLOT public: - void store(const char* method) - { locations[idx++ % Count] = method; } + void store(const char* method) noexcept + { locations[idx++ % locations.size()] = method; } - bool contains(const char *method) const - { return std::find(locations, locations + Count, method) != locations + Count; } + bool contains(const char *method) const noexcept + { return std::find(locations.begin(), locations.end(), method) != locations.end(); } }; Q_THREAD_LOCAL_CONSTINIT static thread_local FlaggedDebugSignatures flaggedSignatures = {};