mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #442] [MERGED] perf: replace O(n) linear route matching with radix trie #575
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#575
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/442
Author: @Divkix
Created: 3/11/2026
Status: ✅ Merged
Merged: 3/11/2026
Merged by: @james-elicx
Base:
main← Head:perf/route-matching-trie📝 Commits (5)
1c9f2c5perf: replace O(n) linear route matching with radix trieb1de57atest: update entry-templates snapshot and assertion for trie-based matchingf284871fix: address review comments on trie-based route matchingfc2823dfix: update matchRoute regex in test to match new 1-arg signature0be0bf4Merge branch 'main' into perf/route-matching-trie📊 Changes
9 files changed (+745 additions, -248 deletions)
View changed files
📝
packages/vinext/src/entries/app-rsc-entry.ts(+13 -10)📝
packages/vinext/src/entries/pages-server-entry.ts(+9 -34)📝
packages/vinext/src/routing/app-router.ts(+16 -51)📝
packages/vinext/src/routing/pages-router.ts(+16 -56)➕
packages/vinext/src/routing/route-trie.ts(+195 -0)📝
tests/__snapshots__/entry-templates.test.ts.snap(+59 -94)📝
tests/entry-templates.test.ts(+3 -2)➕
tests/route-trie.test.ts(+433 -0)📝
tests/shims.test.ts(+1 -1)📄 Description
Closes #444
Summary
route-trie.ts) that replaces O(n) linear route scanning with O(depth) trie-based lookup for all route matchingpages-router.ts,app-router.ts,app-rsc-entry.ts(generated), andpages-server-entry.ts(generated)matchPatternretained only inapp-rsc-entry.tsfor the intercept lookup (0-5 entries, not worth trie-ifying)Test plan
tests/route-trie.test.tscovering: static, dynamic, catch-all, optional catch-all, backtracking, malformed patterns, deeply nested routes, root routes, and full parity with linearmatchPatternrouting.test.ts,route-sorting.test.ts)app-router.test.ts,pages-router.test.ts,features.test.ts)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.