From e08d3251249b034044b1a8336ae08815b3c49c82 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 5 Jan 2022 16:48:05 +0100 Subject: [PATCH] LibJS: Use HashTable::remove_all_matching() in WeakSet :^) --- Userland/Libraries/LibJS/Runtime/WeakSet.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp index 6a40632eb0..f329aa1ec5 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp @@ -25,14 +25,9 @@ WeakSet::~WeakSet() void WeakSet::remove_dead_cells(Badge) { - // FIXME: Do this in a single pass. - Vector to_remove; - for (auto* cell : m_values) { - if (cell->state() != Cell::State::Live) - to_remove.append(cell); - } - for (auto* cell : to_remove) - m_values.remove(cell); + m_values.remove_all_matching([](Cell* cell) { + return cell->state() != Cell::State::Live; + }); } }