Files
ladybird/Libraries/LibGC/WeakHashSet.h
Andreas Kling fc675e8634 LibGC: Amortize pruning of dead entries in WeakHashSet
Previously, every set() and remove() call would do a full O(capacity)
scan of the underlying hash table to remove dead weak references.
This caused significant stalls on pages where the set grew large, as
every insertion paid the full cost of scanning the entire table.

Fix this by tracking mutations since last prune and only performing
the scan after enough operations to amortize the cost. The threshold
scales with the table size (minimum 64), so the per-operation cost
is O(1) amortized.
2026-03-08 20:49:28 +01:00

3.7 KiB