diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-05-16 21:10:44 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-05-17 18:49:31 +0200 |
commit | 53a842f66bcbb7bba63169a2c9bb974ba0f04585 (patch) | |
tree | 9eacb25e6c219593f2e8147ecf64af6c2f5fa087 /src/corelib/kernel/qobject.cpp | |
parent | fd31177c45fa47bab867503d8b1b1505ee81654e (diff) | |
download | qtbase-53a842f66bcbb7bba63169a2c9bb974ba0f04585.tar.gz |
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 <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qobject.cpp')
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index c72b8a761c..1d96110e25 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<const char *, 2> 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 = {}; |