You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: cache special-scheme flag and switch scheme checks to map lookups
- Call protocolComponentMatchesSpecialScheme() once per New() and reuse
the result for both the hostname and pathname branches instead of
matching the component regex against the five special schemes twice.
- Replace specialSchemeList with a single map[string]struct{} so the
per-component lookups in processHostnameForInit and processPathnameForInit
are O(1). protocolComponentMatchesSpecialScheme just iterates the map
keys, since order is irrelevant when the loop returns on the first hit.
- Collapse the port-defaulting loop into a direct DefaultPorts lookup,
which already keys the same five schemes.
~5-10%% reduction in ns/op on New() across pattern benchmarks.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
// If the result running hostname pattern is an IPv6 address given processedInit["hostname"] is true, then set urlPattern’s hostname component to the result of compiling a component given processedInit["hostname"], canonicalize an IPv6 hostname, and hostname options.
0 commit comments