Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e51cb5fa24f6b3641bb0e4e0eedd42a4cdec0afd
https://github.com/WebKit/WebKit/commit/e51cb5fa24f6b3641bb0e4e0eedd42a4cdec0afd
Author: Ahmad Saleem <[email protected]>
Date: 2026-07-18 (Sat, 18 Jul 2026)
Changed paths:
M Source/WebInspectorUI/UserInterface/Workers/Formatter/JSFormatter.js
Log Message:
-----------
Web Inspector: JSFormatter._isRangeWhitespace should avoid allocating a
substring to scan
https://bugs.webkit.org/show_bug.cgi?id=319739
rdar://182579545
Reviewed by Devin Rousso.
_isRangeWhitespace() called this._sourceText.substring(from, to) and
then scanned the resulting substring character-by-character, even
though it only needed to read character codes out of the original
source text.
JSC's String.prototype.substring() doesn't copy the underlying
character buffer; it shares the source StringImpl via a small
substring-view JSString. But outside a few no-allocation fast paths
(empty result, single character, or the whole string), it still
allocates that view object on every call, and reading through it via
charCodeAt() adds an extra layer of indirection versus indexing the
original string directly.
Scan this._sourceText directly by index instead, avoiding that
per-call allocation and indirection. This requires handling from > to
explicitly, since String.prototype.substring() silently swaps its
arguments when indexStart > indexEnd, and some call sites (e.g.
ForStatement semicolon handling) rely on that behavior to check
ranges where the "from" token comes after the "to" node in the
source.
* Source/WebInspectorUI/UserInterface/Workers/Formatter/JSFormatter.js:
(JSFormatter.prototype._isRangeWhitespace):
Canonical link: https://commits.webkit.org/317482@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications