Repository navigation
Commit 910909a
committed
fix: pass url string to URLPattern.exec() in dynamic route matching
Deno's URLPattern implementation runs
webidl.converters["URLPatternInput"] when exec() receives a URL object.
That conversion walks the object's properties on every call and happens
before the internal match cache is consulted, so the cache never helps.
Passing the serialized url skips the conversion layer entirely and hits
the cache directly.
Measured with 6 route patterns, median of 5 rounds x 100k calls:
- Deno 2.9.0 (aarch64-darwin): 4348 -> 221 ns/call (~19.7x)
- Node 24.18.0 (native URLPattern): 2376 -> 1220 ns/call (~1.9x)
The win is specific to runtimes with a JS-based URLPattern (Deno); on
runtimes with a native implementation there is no regression. Reading
url.href costs ~2ns because URL objects cache their serialization.
Refs #19311 parent 86d6cde commit 910909a
1 file changed
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
162 | 169 | | |
163 | 170 | | |
164 | 171 | | |
| |||
0 commit comments