diff --git a/Userland/Libraries/LibJS/Runtime/WeakMap.cpp b/Userland/Libraries/LibJS/Runtime/WeakMap.cpp index 4a375df62f..9195b4de6c 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMap.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMap.cpp @@ -25,14 +25,9 @@ WeakMap::~WeakMap() void WeakMap::remove_dead_cells(Badge) { - // FIXME: Do this in a single pass. - Vector 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); + m_values.remove_all_matching([](Cell* key, Value) { + return key->state() != Cell::State::Live; + }); } void WeakMap::visit_edges(Visitor& visitor)