From 7a05bb5cfbf3560b828c226f4a3bad8c3826b039 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Wed, 23 Mar 2022 18:47:42 +0100 Subject: Apply changes suggested by clang-tidy 11 --- test/buildtool/logging/logger.test.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'test/buildtool/logging/logger.test.cpp') diff --git a/test/buildtool/logging/logger.test.cpp b/test/buildtool/logging/logger.test.cpp index 329b69b0..ac28889b 100644 --- a/test/buildtool/logging/logger.test.cpp +++ b/test/buildtool/logging/logger.test.cpp @@ -9,25 +9,32 @@ // Stores prints from test sink instances class TestPrints { + struct PrintData { + std::atomic counter{}; + std::unordered_map> prints{}; + }; + public: static void Print(int sink_id, std::string const& print) noexcept { - prints_[sink_id].push_back(print); + Data().prints[sink_id].push_back(print); } [[nodiscard]] static auto Read(int sink_id) noexcept -> std::vector { - return prints_[sink_id]; + return Data().prints[sink_id]; } static void Clear() noexcept { - prints_.clear(); - counter_ = 0; + Data().prints.clear(); + Data().counter = 0; } - static auto GetId() noexcept -> int { return counter_++; } + static auto GetId() noexcept -> int { return Data().counter++; } private: - static inline std::atomic counter_{}; - static inline std::unordered_map> prints_{}; + [[nodiscard]] static auto Data() noexcept -> PrintData& { + static PrintData instance{}; + return instance; + } }; // Test sink, prints to TestPrints depending on its own instance id. -- cgit v1.2.3