From cb9301f03191e02cae09057a6082a3d3f0810eeb Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 11:20:00 +0000 Subject: [PATCH] perf(router): compare a part's first character directly when building the tree `segment[0] === '{'` is one keyed load and a compare in the interpreter, where `segment.charCodeAt(0) === 123` loads the method and calls it. It is also easier to read. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VVaw7Sutbw6xMTMyDFeNfw --- packages/router/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/router/src/index.ts b/packages/router/src/index.ts index 1205cc5..929c21e 100644 --- a/packages/router/src/index.ts +++ b/packages/router/src/index.ts @@ -405,7 +405,7 @@ function expand(node: Node, pending: unknown[], start: number, whole: bool // first part, a route waits before one, and before literal text like it, // which keeps the first of two that read the same. A route added whole // goes after the routes waiting there. - if (segment.charCodeAt(0) === 123) { + if (segment[0] === '{') { if (!whole && index > start) { if (index < literals) { literals = index