From 87a43fa87c4bf787e92973edc6f5503d7dcce798 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 18 Apr 2021 18:12:33 +0200 Subject: [PATCH] LibJS: Use 'if constexpr' instead of '#if HEAP_DEBUG' --- Userland/Libraries/LibJS/Heap/Heap.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Userland/Libraries/LibJS/Heap/Heap.cpp b/Userland/Libraries/LibJS/Heap/Heap.cpp index d0351af1be..b27586f112 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.cpp +++ b/Userland/Libraries/LibJS/Heap/Heap.cpp @@ -116,11 +116,11 @@ void Heap::gather_roots(HashTable& roots) } } -#if HEAP_DEBUG - dbgln("gather_roots:"); - for (auto* root : roots) - dbgln(" + {}", root); -#endif + if constexpr (HEAP_DEBUG) { + dbgln("gather_roots:"); + for (auto* root : roots) + dbgln(" + {}", root); + } } __attribute__((no_sanitize("address"))) void Heap::gather_conservative_roots(HashTable& roots) @@ -239,12 +239,12 @@ void Heap::sweep_dead_cells(bool print_report, const Core::ElapsedTimer& measure allocator_for_size(block->cell_size()).block_did_become_usable({}, *block); } -#if HEAP_DEBUG - for_each_block([&](auto& block) { - dbgln(" > Live HeapBlock @ {}: cell_size={}", &block, block.cell_size()); - return IterationDecision::Continue; - }); -#endif + if constexpr (HEAP_DEBUG) { + for_each_block([&](auto& block) { + dbgln(" > Live HeapBlock @ {}: cell_size={}", &block, block.cell_size()); + return IterationDecision::Continue; + }); + } int time_spent = measurement_timer.elapsed();