Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: c96c07c35cc49de658a762231a6f984545f714ce
https://github.com/WebKit/WebKit/commit/c96c07c35cc49de658a762231a6f984545f714ce
Author: Sosuke Suzuki <[email protected]>
Date: 2026-07-01 (Wed, 01 Jul 2026)
Changed paths:
A JSTests/microbenchmarks/encode-uri-component-query-string.js
A JSTests/microbenchmarks/encode-uri-component-unicode.js
M Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
Log Message:
-----------
[JSC] Use direct 3-character append for `"%XY"` escapes in `encode()`
https://bugs.webkit.org/show_bug.cgi?id=318334
Reviewed by Yusuke Suzuki.
encode() (shared by encodeURIComponent / encodeURI / escape) emits each
escaped octet with two StringBuilder appends, where the second one goes
through the generic hex() adapter: it constructs a HexNumberBuffer and
runs the out-of-line arbitrary-width hex loop plus string-adapter
dispatch per octet. This dominates the profile on escape-heavy inputs.
Build the "%XY" triple on the stack with the constexpr nibble helpers
from wtf/ASCIICType.h and append it once. The output is byte-identical.
Baseline Patched
encode-uri-component-unicode 71.1958+-1.1739 ^
52.1049+-1.0046 ^ definitely 1.3664x faster
encode-uri-component-query-string 78.8259+-2.7355 ^
61.2906+-1.1368 ^ definitely 1.2861x faster
Tests: JSTests/microbenchmarks/encode-uri-component-query-string.js
JSTests/microbenchmarks/encode-uri-component-unicode.js
* JSTests/microbenchmarks/encode-uri-component-query-string.js: Added.
* JSTests/microbenchmarks/encode-uri-component-unicode.js: Added.
* Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:
(JSC::encode):
Canonical link: https://commits.webkit.org/316343@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications