Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 8fd53d6aae4012312ec941204e18688faca3fcb3
https://github.com/WebKit/WebKit/commit/8fd53d6aae4012312ec941204e18688faca3fcb3
Author: Ahmad Saleem <[email protected]>
Date: 2026-09-13 (Sun, 13 Sep 2026)
Changed paths:
M Source/WebCore/platform/network/cocoa/CookieCocoa.mm
Log Message:
-----------
Cookie::operator== and Cookie::hash() build NSHTTPCookie objects on every
hash-table operation
https://bugs.webkit.org/show_bug.cgi?id=324057
rdar://187289096
Reviewed by Chris Dumez.
On Cocoa, Cookie::operator== constructed two NSHTTPCookie objects (via
createNSHTTPCookie()) and compared them with -isEqual:, and Cookie::hash()
constructed one NSHTTPCookie per call and returned its -hash. Each
createNSHTTPCookie() allocates an NSMutableDictionary of up to 14 entries,
bridges every WTF field into NSString/NSURL/NSDate objects, formats the port
list into a string, and constructs an NSHTTPCookie via +cookieWithProperties:.
Both functions are hot in hash-table operations -- Cookie is a hash-table key
(HashTraits<WebCore::Cookie> in Cookie.h) and is stored in ListHashSet<Cookie>
(e.g. InspectorPageAgent) -- so every insert and lookup paid for one or two
full NSHTTPCookie constructions.
Compare and hash the WTF data members directly instead, matching the
field-based implementation already used by the non-Cocoa platforms in
Cookie.cpp. This removes all NSHTTPCookie allocations from the equality and
hashing paths. Equality now uses strict member-wise comparison over all
fields rather than CFNetwork's normalized -isEqual:, which is the correct
definition for hash keying (equal fields imply an equal cookie) and keeps
hash() consistent with operator== so equal cookies still hash equal.
* Source/WebCore/platform/network/cocoa/CookieCocoa.mm:
(WebCore::Cookie::operator== const): Compare WTF fields directly.
(WebCore::Cookie::hash const): Hash WTF fields directly via computeHash().
Canonical link: https://commits.webkit.org/321018@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications