Skip to content

Commit 41fac3f

Browse files
authored
refactor(router-core): findSingleMatch caches the trees it generate in an LRUCache, not a Map (#5878)
1 parent 8994fc1 commit 41fac3f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/router-core/src/new-process-route-tree.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ export type ProcessedTree<
535535
/** a mini route tree generated from the flat `routeMasks` list */
536536
masksTree: AnySegmentNode<TFlat> | null
537537
/** @deprecated keep until v2 so that `router.matchRoute` can keep not caring about the actual route tree */
538-
singleCache: Map<any, AnySegmentNode<TSingle>>
538+
singleCache: LRUCache<string, AnySegmentNode<TSingle>>
539539
/** a cache of route matches from the `segmentTree` */
540540
matchCache: LRUCache<string, ReturnType<typeof findMatch<TTree>>>
541541
/** a cache of route matches from the `masksTree` */
@@ -675,7 +675,7 @@ export function processRouteTree<
675675
sortTreeNodes(segmentTree)
676676
const processedTree: ProcessedTree<TRouteLike, any, any> = {
677677
segmentTree,
678-
singleCache: new Map(),
678+
singleCache: createLRUCache<string, AnySegmentNode<any>>(1000),
679679
matchCache: createLRUCache<
680680
string,
681681
ReturnType<typeof findMatch<TRouteLike>>

0 commit comments

Comments
 (0)