Jelajahi Sumber

LibJS: Use HashTable::remove_all_matching() in WeakSet :^)

Andreas Kling 3 tahun lalu
induk
melakukan
e08d325124
1 mengubah file dengan 3 tambahan dan 8 penghapusan
  1. 3 8
      Userland/Libraries/LibJS/Runtime/WeakSet.cpp

+ 3 - 8
Userland/Libraries/LibJS/Runtime/WeakSet.cpp

@@ -25,14 +25,9 @@ WeakSet::~WeakSet()
 
 void WeakSet::remove_dead_cells(Badge<Heap>)
 {
-    // FIXME: Do this in a single pass.
-    Vector<Cell*> 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;
+    });
 }
 
 }