summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/WeakMap.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-01-05 16:57:16 +0100
committerAndreas Kling <kling@serenityos.org>2022-01-05 18:57:14 +0100
commitc7ac0c2c80c70b906ad1ca1b60cea37ad111661f (patch)
treef45ed0dfa88f242feecabad40041f3b5b42797ff /Userland/Libraries/LibJS/Runtime/WeakMap.cpp
parent376e5ef9125fcc7c17c2b96f14cb4b64b28e191a (diff)
downloadserenity-c7ac0c2c80c70b906ad1ca1b60cea37ad111661f.zip
LibJS: Use HashMap::remove_all_matching() in WeakMap
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/WeakMap.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakMap.cpp11
1 files changed, 3 insertions, 8 deletions
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<Heap>)
{
- // 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);
+ m_values.remove_all_matching([](Cell* key, Value) {
+ return key->state() != Cell::State::Live;
+ });
}
void WeakMap::visit_edges(Visitor& visitor)