mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
LibJS: Make WeakContainer pruning do less work
Instead of iterating *all* swept cells when pruning weak containers, only iterate the cells actually *in* the container. Also, instead of compiling a list of all swept cells, we can simply check the Cell::state() flag to know if something should be pruned.
This commit is contained in:
parent
19fc225b45
commit
83bd675477
10 changed files with 39 additions and 35 deletions
|
@ -23,9 +23,15 @@ WeakMap::~WeakMap()
|
|||
{
|
||||
}
|
||||
|
||||
void WeakMap::remove_swept_cells(Badge<Heap>, Span<Cell*> cells)
|
||||
void WeakMap::remove_dead_cells(Badge<Heap>)
|
||||
{
|
||||
for (auto* cell : cells)
|
||||
// FIXME: Do this in a single pass.
|
||||
Vector<Cell*> to_remove;
|
||||
for (auto& it : m_values) {
|
||||
if (it.key->state() != Cell::State::Live)
|
||||
to_remove.append(it.key);
|
||||
}
|
||||
for (auto* cell : to_remove)
|
||||
m_values.remove(cell);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue