Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b0d52573ef1d019347c8f3ef4d5fc95866106572
      
https://github.com/WebKit/WebKit/commit/b0d52573ef1d019347c8f3ef4d5fc95866106572
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-07-13 (Mon, 13 Jul 2026)

  Changed paths:
    M Source/WebCore/Modules/fetch/FetchHeaders.cpp

  Log Message:
  -----------
  FetchHeaders::appendToHeaderMap does a redundant header-map lookup on every 
append
https://bugs.webkit.org/show_bug.cgi?id=318701
rdar://181516418

Reviewed by Chris Dumez.

When appending a header, appendToHeaderMap() called 
HTTPHeaderMap::contains(name)
and then HTTPHeaderMap::get(name) to build the combined value. Both calls 
perform
the same resolution work -- findHTTPHeaderName() followed by a common-header 
probe
or a linear scan of the uncommon headers -- so every appended header paid for 
two
identical lookups.

HTTPHeaderMap::get() already returns a null String when the header is absent, 
and
a present header always stores a non-null value, so a single get() plus an
isNull() check is equivalent to the contains()/get() pair. Collapse the two
lookups into one.

The optimization relies on the invariant that a header present in the map never
stores a null value. To guard against that invariant silently breaking, assert
it in debug builds before relying on the isNull() check.

No change in behavior; covered by existing fetch tests.

* Source/WebCore/Modules/fetch/FetchHeaders.cpp:
(WebCore::appendToHeaderMap):

Canonical link: https://commits.webkit.org/317044@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to