mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:27:43 +00:00
LibJS: Use HashMap::remove_all_matching() in WeakMap
This commit is contained in:
parent
376e5ef912
commit
c7ac0c2c80
1 changed files with 3 additions and 8 deletions
|
@ -25,14 +25,9 @@ WeakMap::~WeakMap()
|
||||||
|
|
||||||
void WeakMap::remove_dead_cells(Badge<Heap>)
|
void WeakMap::remove_dead_cells(Badge<Heap>)
|
||||||
{
|
{
|
||||||
// FIXME: Do this in a single pass.
|
m_values.remove_all_matching([](Cell* key, Value) {
|
||||||
Vector<Cell*> to_remove;
|
return key->state() != Cell::State::Live;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WeakMap::visit_edges(Visitor& visitor)
|
void WeakMap::visit_edges(Visitor& visitor)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue