Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e1fc460b8f1d82f50a1165573faca85fb9636352
https://github.com/WebKit/WebKit/commit/e1fc460b8f1d82f50a1165573faca85fb9636352
Author: David Kilzer <[email protected]>
Date: 2026-07-27 (Mon, 27 Jul 2026)
Changed paths:
M Source/WTF/wtf/RobinHoodHashTable.h
M Source/WebCore/Modules/web-locks/WebLockRegistry.cpp
M Source/WebCore/dom/TreeScope.cpp
M
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
M
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm
M Tools/TestWebKitAPI/Tests/WTF/RobinHoodHashMap.cpp
M Tools/TestWebKitAPI/Tests/WTF/RobinHoodHashSet.cpp
Log Message:
-----------
Add removeIf() to WTF::RobinHoodHashTable and adopt it to simplify
remove-matching-entries loops
<https://bugs.webkit.org/show_bug.cgi?id=320337>
<rdar://183275236>
Reviewed by Yusuke Suzuki.
`WTF::HashTable` and its `Weak*` wrappers provide `removeIf()`, but
`WTF::RobinHoodHashTable` did not, so the RobinHood-backed
`HashMap`/`HashSet` variants failed to compile any `removeIf()` call.
Several WebCore sites backed by RobinHood maps therefore collected
matching entries into a temporary `Vector` and then removed them in a
second loop.
`RobinHoodHashTable` uses backward-shift deletion rather than tombstones,
so it cannot reuse `HashTable::removeIf()`: deleting a match shifts a
following entry into the current slot, so the sweep must re-examine that
slot, and it must defer `shrink()` (which rehashes) to a single
`shrinkToBestSize()` at the end. Factor the backward-shift core of
`remove()` into `shiftDeleteWithoutShrink()` for `removeIf()` to reuse.
Tests: TestWTF.WTF_RobinHoodHashSet.RemoveIf
TestWTF.WTF_RobinHoodHashSet.RemoveIfLarge
TestWTF.WTF_RobinHoodHashMap.RemoveIf
TestWTF.WTF_RobinHoodHashMap.RemoveIfLarge
* Source/WTF/wtf/RobinHoodHashTable.h:
(WTF::RobinHoodHashTable::shiftDeleteWithoutShrink): Add.
(WTF::RobinHoodHashTable::remove):
(WTF::RobinHoodHashTable::removeIf): Add.
* Source/WebCore/Modules/web-locks/WebLockRegistry.cpp:
(WebCore::LocalWebLockRegistry::PerOriginRegistry::clientsAreGoingAway):
* Source/WebCore/dom/TreeScope.cpp:
(WebCore::TreeScope::removeElementFromPendingSVGResources):
*
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::keyAdded):
*
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::updateTracksOfKind):
* Tools/TestWebKitAPI/Tests/WTF/RobinHoodHashMap.cpp:
(TestWebKitAPI::TEST(WTF_RobinHoodHashMap, RemoveIf)): Add.
(TestWebKitAPI::TEST(WTF_RobinHoodHashMap, RemoveIfLarge)): Add.
* Tools/TestWebKitAPI/Tests/WTF/RobinHoodHashSet.cpp:
(TestWebKitAPI::TEST(WTF_RobinHoodHashSet, RemoveIf)): Add.
(TestWebKitAPI::TEST(WTF_RobinHoodHashSet, RemoveIfLarge)): Add.
Canonical link: https://commits.webkit.org/318010@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications