From 7cdcc833b5e3a9b2d3194875d4b9e7d4446b5077 Mon Sep 17 00:00:00 2001 From: podumai Date: Mon, 30 Mar 2026 01:20:16 +0700 Subject: [PATCH 1/3] refactor: remove test scoped timer --- app/main.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index ff0093d..cd0308b 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -18,26 +18,10 @@ constexpr int kBytesToAllocate{64}; } -class [[nodiscard]] ScopedTimer { - public: - ~ScopedTimer() { - try { - std::println( - "{}", std::chrono::duration_cast(std::chrono::steady_clock::now() - start_) - ); - } catch (...) { - } - } - - private: - std::chrono::steady_clock::time_point start_{std::chrono::steady_clock::now()}; -}; - auto main() -> int { try { lab::memory::PoolMemoryResource pool_resource{lab::memory::NewMemoryResource::Instance()}; lab::memory::PoolAllocator pool_allocator{&pool_resource}; - ScopedTimer timer{}; int* arr{pool_allocator.allocate(10)}; std::iota(arr, arr + 10, 0); std::for_each(arr, arr + 10, [counter = 0, arr](int& value) mutable -> void { From f88c81b367fc0a7c9749081562448207dc235662 Mon Sep 17 00:00:00 2001 From: podumai Date: Mon, 30 Mar 2026 01:22:51 +0700 Subject: [PATCH 2/3] refactor: add named constant for element count --- app/main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index cd0308b..17ace29 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -15,16 +15,17 @@ namespace { constexpr int kBytesToAllocate{64}; +constexpr std::size_t kElementsCount{10}; } auto main() -> int { try { - lab::memory::PoolMemoryResource pool_resource{lab::memory::NewMemoryResource::Instance()}; + lab::memory::PoolMemoryResource pool_resource{lab::memory::NewMemoryResource::Instance()}; lab::memory::PoolAllocator pool_allocator{&pool_resource}; - int* arr{pool_allocator.allocate(10)}; - std::iota(arr, arr + 10, 0); - std::for_each(arr, arr + 10, [counter = 0, arr](int& value) mutable -> void { + int* arr{pool_allocator.allocate(kElementsCount)}; + std::iota(arr, arr + kElementsCount, 0); + std::for_each(arr, arr + kElementsCount, [counter = 0, arr](int& value) mutable -> void { arr[counter] = counter; std::println("arr[{}] = {}", counter, arr[counter]); ++counter; From 3e12b9dbd5647ecb4b53358870e339382324bbf6 Mon Sep 17 00:00:00 2001 From: podumai Date: Mon, 30 Mar 2026 01:24:47 +0700 Subject: [PATCH 3/3] chore: add linter directives to prevent false positives --- app/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 17ace29..8f185c9 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -24,10 +24,10 @@ auto main() -> int { lab::memory::PoolMemoryResource pool_resource{lab::memory::NewMemoryResource::Instance()}; lab::memory::PoolAllocator pool_allocator{&pool_resource}; int* arr{pool_allocator.allocate(kElementsCount)}; - std::iota(arr, arr + kElementsCount, 0); - std::for_each(arr, arr + kElementsCount, [counter = 0, arr](int& value) mutable -> void { - arr[counter] = counter; - std::println("arr[{}] = {}", counter, arr[counter]); + std::iota(arr, arr + kElementsCount, 0); // NOLINT + std::for_each(arr, arr + kElementsCount, [counter = 0, arr](int& value) mutable -> void { // NOLINT + arr[counter] = counter; // NOLINT + std::println("arr[{}] = {}", counter, arr[counter]); // NOLINT ++counter; }); } catch (const std::exception& error) {