url: speed up URLPattern - #24
Open
anonrig wants to merge 1 commit into
Open
Conversation
anonrig
marked this pull request as ready for review
August 18, 2026 01:50
cursor
Bot
force-pushed
the
cursor/urlpattern-performance-603e
branch
2 times, most recently
from
August 18, 2026 12:49
52a2a71 to
a2e81de
Compare
Avoid extra UTF-8 copies on constructor, test, and exec; convert regexp inputs with ToV8Value; and assign URLPatternInit fields by interned key instead of string-comparing each component name. Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
cursor
Bot
force-pushed
the
cursor/urlpattern-performance-603e
branch
from
August 18, 2026 12:50
a2e81de to
b1e8b1d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This speeds up WHATWG
URLPatternconstructor,test(), andexec()without changing observable behavior.Independent of the
new URL()parse PR (nodejs#65361) and theURLSearchParamsPR (nodejs#65363).What changed
C++ only (
src/node_url_pattern.cc):ValueView+memcpyinto a stack buffer and pass astring_viewinto Ada. Drop the extrastd::stringcopy thatBufferValue/Utf8Value::ToString()used to make. Non-ASCII still goes throughUtf8Value.ToV8Valueand useisolate->GetCurrentContext()instead ofEnvironment::GetCurrent.test/exec: share argument parsing so both paths keep the same WebIDL null/undefined/"null"baseURL behavior.Ada still owns its parsed state;
string_views only live for the duration of the C++ call.ValueViewis destroyed before any V8 heap allocation.Tests
test/parallel/test-urlpattern.js,test-urlpattern-types.js,test-urlpattern-invalidthis.js, andtest-urlpattern-fast-path.jsall passtest/wpt/test-urlpattern.js: 743 passed, 0 unexpected failuresReview follow-up
NewStringFromUtf8Viewhelper in favor ofToV8ValueCopyV8StringToBuffertakes a pointer, matching project convention for mutating argumentsSigned-off-byfrom the commit (AI agents cannot attest DCO)