From 7a8ffbcf9ceb0efff7c54b823ad6bdca388a6985 Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 5 Aug 2024 04:45:41 +1100 Subject: [PATCH] perf(matcher): use associative string access instead of `endsWith` in `normalizePath` in my case it gives a double speedup of the function --- packages/router/src/matcher/matcherTree.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/router/src/matcher/matcherTree.ts b/packages/router/src/matcher/matcherTree.ts index aaf889762..9f676d7eb 100644 --- a/packages/router/src/matcher/matcherTree.ts +++ b/packages/router/src/matcher/matcherTree.ts @@ -13,7 +13,7 @@ function normalizePath(path: string) { path = path.toUpperCase() // TODO: Check more thoroughly whether this is really necessary - while (path.endsWith('/')) { + while (path[path.length - 1] === '/') { path = path.slice(0, -1) }