1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 08:25:07 +00:00

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

View file

@ -118,15 +118,11 @@ void Heap::mark_live_cells(const HashTable<Cell*>& live_cells)
#ifdef HEAP_DEBUG #ifdef HEAP_DEBUG
dbg() << "mark_live_cells:"; dbg() << "mark_live_cells:";
#endif #endif
for (auto& block : m_blocks) { for (auto& cell : live_cells) {
block->for_each_cell([&](Cell* cell) {
if (live_cells.contains(cell)) {
#ifdef HEAP_DEBUG #ifdef HEAP_DEBUG
dbg() << " ! " << cell; dbg() << " ! " << cell;
#endif #endif
cell->set_marked(true); cell->set_marked(true);
}
});
} }
} }