Skip to content

Avoid unnecessary AtomString creation in bestFitSourceForImageAttributes callers#63208

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
cdumez:312863_bestFitSourceForImageAttributes
Apr 22, 2026
Merged

Avoid unnecessary AtomString creation in bestFitSourceForImageAttributes callers#63208
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
cdumez:312863_bestFitSourceForImageAttributes

Conversation

@cdumez
Copy link
Copy Markdown
Contributor

@cdumez cdumez commented Apr 21, 2026

3e936c5

Avoid unnecessary AtomString creation in bestFitSourceForImageAttributes callers
https://bugs.webkit.org/show_bug.cgi?id=312863

Reviewed by Darin Adler and Ryosuke Niwa.

bestFitSourceForImageAttributes() was taking `const AtomString&` for its
srcAttribute parameter, but only calls isNull(), isEmpty(), and passed it to
StringViewWithUnderlyingString — none of which require AtomString. Three of its
five callers constructed a temporary AtomString from a String just to satisfy the
signature, which hashes the string and inserts it into the global atom table for
no benefit.

Change the parameter type to `const String&`. The two callers that already pass
AtomString (HTMLImageElement) work without changes via implicit conversion.

* Source/WebCore/html/parser/HTMLPreloadScanner.cpp:
(WebCore::TokenPreloadScanner::StartTagScanner::processAttributes):
* Source/WebCore/html/parser/HTMLSrcsetParser.cpp:
(WebCore::bestFitSourceForImageAttributes):
* Source/WebCore/html/parser/HTMLSrcsetParser.h:
(WebCore::bestFitSourceForImageAttributes):
* Source/WebCore/loader/LinkLoader.cpp:
(WebCore::LinkLoader::preloadIfNeeded):

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

b988ea3

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe 🛠 win ⏳ 🛠 ios-apple
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 🧪 win-tests ⏳ 🛠 mac-apple
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 🧪 api-mac ✅ 🧪 api-wpe ⏳ 🛠 vision-apple
🧪 ios-wk2-wpt 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🛠 ios-safer-cpp ✅ 🧪 mac-wk2 🧪 gtk-wk2
✅ 🛠 vision 🧪 mac-AS-debug-wk2 ❌ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🛠 playstation
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@cdumez cdumez self-assigned this Apr 21, 2026
@cdumez cdumez added the DOM For bugs specific to XML/HTML DOM elements (including parsing). label Apr 21, 2026
@cdumez cdumez marked this pull request as ready for review April 21, 2026 09:25
@cdumez cdumez requested a review from rniwa as a code owner April 21, 2026 09:25
@cdumez cdumez added the merge-queue Applied to send a pull request to merge-queue label Apr 22, 2026
@webkit-commit-queue webkit-commit-queue force-pushed the 312863_bestFitSourceForImageAttributes branch from cdebfce to e28a60d Compare April 22, 2026 01:43
@cdumez cdumez removed the merge-queue Applied to send a pull request to merge-queue label Apr 22, 2026
@cdumez cdumez force-pushed the 312863_bestFitSourceForImageAttributes branch from e28a60d to b988ea3 Compare April 22, 2026 03:16
@cdumez cdumez added the merge-queue Applied to send a pull request to merge-queue label Apr 22, 2026
…tes callers

https://bugs.webkit.org/show_bug.cgi?id=312863

Reviewed by Darin Adler and Ryosuke Niwa.

bestFitSourceForImageAttributes() was taking `const AtomString&` for its
srcAttribute parameter, but only calls isNull(), isEmpty(), and passed it to
StringViewWithUnderlyingString — none of which require AtomString. Three of its
five callers constructed a temporary AtomString from a String just to satisfy the
signature, which hashes the string and inserts it into the global atom table for
no benefit.

Change the parameter type to `const String&`. The two callers that already pass
AtomString (HTMLImageElement) work without changes via implicit conversion.

* Source/WebCore/html/parser/HTMLPreloadScanner.cpp:
(WebCore::TokenPreloadScanner::StartTagScanner::processAttributes):
* Source/WebCore/html/parser/HTMLSrcsetParser.cpp:
(WebCore::bestFitSourceForImageAttributes):
* Source/WebCore/html/parser/HTMLSrcsetParser.h:
(WebCore::bestFitSourceForImageAttributes):
* Source/WebCore/loader/LinkLoader.cpp:
(WebCore::LinkLoader::preloadIfNeeded):

Canonical link: https://commits.webkit.org/311751@main
@webkit-commit-queue webkit-commit-queue force-pushed the 312863_bestFitSourceForImageAttributes branch from b988ea3 to 3e936c5 Compare April 22, 2026 05:30
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 311751@main (3e936c5): https://commits.webkit.org/311751@main

Reviewed commits have been landed. Closing PR #63208 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 3e936c5 into WebKit:main Apr 22, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DOM For bugs specific to XML/HTML DOM elements (including parsing).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants