Merge pull request 'perf(router): reset the walk stack only when a lookup throws (#109)' (#131) from fix/router-walk-stack-reset into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 15s
CI / build (push) Successful in 25s
CI / runtimes (deno) (push) Successful in 19s
CI / runtimes (edge) (push) Successful in 14s
Promote → GitHub / push-github (push) Successful in 7s

This commit was merged in pull request #131.
This commit is contained in:
chrnx committed 2026-10-12 20:10:44 +00:00
commit d07d6add04
1 file changed
+4 -1
+4 -1
View File
@@ -612,10 +612,13 @@ function walk(root: RadixNode, search: Search, segs: string[]): void {
stackDepths.push(depth + 1);
}
}
} finally {
} catch (error) {
// A malformed `%` escape throws out of `decodeSegment` with frames still pending; drop them.
// Not in a `finally`: a normal walk already ends at `base`, and writing `length` on every lookup
// drops the arrays' storage, which cost D4 at 10 routes (FPRD-001 CARD-10).
stackNodes.length = base;
stackDepths.length = base;
throw error;
}
}