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! :^)
This commit is contained in:
Andreas Kling 2020-03-09 19:36:15 +01:00
parent 0de2ead0e9
commit c6e54d2a49
Notes: sideshowbarker 2024-07-19 08:48:43 +09:00

View file

@ -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);
}
}