Skip to content

Commit 2b3c398

Browse files
committed
refactor: remove splice as sort mutates array
1 parent 36c9835 commit 2b3c398

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

packages/router/src/matcher/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,17 +366,15 @@ export function createRouterMatcher(
366366
// restore matcher order from cache
367367
if (globalOptions.sortCache != null) {
368368
try {
369-
const sorted = matchers.sort(
369+
matchers.sort(
370370
(a, b) =>
371371
globalOptions!.sortCache![a.cacheKey!] -
372372
globalOptions!.sortCache![b.cacheKey!]
373373
)
374374

375-
for (const entry of sorted) {
375+
for (const entry of matchers) {
376376
delete entry.cacheKey
377377
}
378-
379-
matchers.splice(0, matchers.length, ...sorted)
380378
} catch {
381379
console.log('Restore failure.')
382380
}

0 commit comments

Comments
 (0)