summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-09 19:36:15 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-09 19:36:15 +0100
commitc6e54d2a49cf70ffebbeced28dba34405c6d7e41 (patch)
treea94d40a349e97f4386825993927b8aaaeeebe865
parent0de2ead0e91f28ffec2bddd60dec24c0db75b275 (diff)
downloadserenity-c6e54d2a49cf70ffebbeced28dba34405c6d7e41.zip
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! :^)
-rw-r--r--Libraries/LibJS/Heap.cpp10
1 files 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<Cell*>& 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);
}
}