You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 38bcd32
Browse filesBrowse the repository at this point in the historyBrowse files
Optimize looking up keys by raw reference in hash containers whose key is a non-nullable smart pointer type
https://bugs.webkit.org/show_bug.cgi?id=266166
Reviewed by Darin Adler.
Optimize looking up keys by raw reference in hash containers whose key is a
non-nullable smart pointer type (such as Ref<> / WeakRef<> / CheckedRef<>).
I noticed while adopting WeakRef<> more in our containers that hash container
functions can be passed a raw C++ reference. This is convenient but actually
generates unnecessary refcounting churn for many of these functions because
it creates a WeakRef. Creating a WeakRef is unnecessary for lookup functions
such as contains() / find() and removal functions such as remove() / take().
We already had overloads in place for these functions when passing in
a raw C++ pointer and the key is a smart pointer type to avoid refcounting
churn. However, we didn't have such optimization when passing a raw C++
reference, which is useful when the key type is a non-nullable smart pointer.
This patch adds to our hash containers function overloads that take in a
raw C++ reference, similar to the ones that take in a raw C++ pointer. These
overloads are only available when the key is a non-nullable smart pointer
type.
I also make an improvement to our existing overloads taking in a raw C++
pointer so that they no longer require a non-const pointer. There is no
reason to require a non-const pointer just for pointer hashing and pointer
comparison. I also noticed this issue when adopting more smart pointers in
containers.
* Source/JavaScriptCore/runtime/Identifier.h:
(JSC::IdentifierRepHash::hash):
* Source/WTF/wtf/CheckedPtr.h:
* Source/WTF/wtf/CheckedRef.h:
* Source/WTF/wtf/CompactPtr.h:
* Source/WTF/wtf/ConcurrentPtrHashSet.h:
* Source/WTF/wtf/GetPtr.h:
* Source/WTF/wtf/HashCountedSet.h:
(WTF::Traits>::find):
(WTF::Traits>::find const):
(WTF::Traits>::contains const):
(WTF::Traits>::count const):
(WTF::Traits>::remove):
* Source/WTF/wtf/HashFunctions.h:
* Source/WTF/wtf/HashMap.h:
(WTF::Y>::find):
(WTF::Y>::find const):
(WTF::Y>::contains const):
(WTF::Y>::inlineGet const):
(WTF::Y>::get const):
(WTF::Y>::remove):
(WTF::Y>::take):
* Source/WTF/wtf/HashSet.h:
(WTF::TableTraits>::find const):
(WTF::TableTraits>::contains const):
(WTF::TableTraits>::remove):
(WTF::TableTraits>::take):
* Source/WTF/wtf/ListHashSet.h:
(WTF::U>::find):
(WTF::U>::find const):
(WTF::U>::contains const):
(WTF::U>::insertBefore):
(WTF::U>::remove):
* Source/WTF/wtf/Packed.h:
* Source/WTF/wtf/Ref.h:
* Source/WTF/wtf/RefPtr.h:
* Source/WTF/wtf/RetainPtr.h:
* Source/WTF/wtf/SchedulePair.h:
(WTF::SchedulePairHash::hash):
(WTF::SchedulePairHash::equal):
* Source/WTF/wtf/SignedPtr.h:
* Source/WTF/wtf/UniqueRef.h:
* Source/WTF/wtf/WeakPtr.h:
(WTF::WeakPtr::WeakPtr):
* Source/WTF/wtf/WeakRef.h:
(WTF::WeakRef::releaseImpl):
(WTF::WeakRefHashTraits::take):
* Source/WTF/wtf/glib/GRefPtr.h:
* Source/WTF/wtf/text/StringHash.h:
(WTF::StringHash::hash):
(WTF::ASCIICaseInsensitiveHash::hash):
* Source/WebCore/dom/GCReachableRef.h:
* Source/WebCore/page/SecurityOriginHash.h:
(WebCore::SecurityOriginHash::hash):
(WebCore::SecurityOriginHash::equal):
* Source/WebCore/platform/win/COMPtr.h:
* Source/WebCore/rendering/FloatingObjects.h:
(WebCore::FloatingObjectHashFunctions::hash):
(WebCore::FloatingObjectHashFunctions::equal):
* Source/WebCore/rendering/GlyphDisplayListCache.h:
(WebCore::GlyphDisplayListCacheEntryHash::hash):
(WebCore::GlyphDisplayListCacheEntryHash::equal):
* Source/WebKit/UIProcess/API/cpp/WKRetainPtr.h:
* Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp:
(TestWebKitAPI::TestType::resetDidUpdateImplRefCount):
(TestWebKitAPI::TestType::didUpdateImplRefCount const):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/271853@main
0 commit comments