From c6e54d2a49cf70ffebbeced28dba34405c6d7e41 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 9 Mar 2020 19:36:15 +0100 Subject: [PATCH] LibJS: Simplify Heap::mark_live_cells() Instead of iterating over every single cell, simply iterate over the live cells and mark them from there. Thanks to Blam for suggesting this! :^) --- Libraries/LibJS/Heap.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Libraries/LibJS/Heap.cpp b/Libraries/LibJS/Heap.cpp index 035cf9dc3a..33ce668c54 100644 --- a/Libraries/LibJS/Heap.cpp +++ b/Libraries/LibJS/Heap.cpp @@ -118,15 +118,11 @@ void Heap::mark_live_cells(const HashTable& live_cells) #ifdef HEAP_DEBUG dbg() << "mark_live_cells:"; #endif - for (auto& block : m_blocks) { - block->for_each_cell([&](Cell* cell) { - if (live_cells.contains(cell)) { + for (auto& cell : live_cells) { #ifdef HEAP_DEBUG - dbg() << " ! " << cell; + dbg() << " ! " << cell; #endif - cell->set_marked(true); - } - }); + cell->set_marked(true); } }