diff --git a/packages/router/src/index.ts b/packages/router/src/index.ts index 929c21e..c6af03f 100644 --- a/packages/router/src/index.ts +++ b/packages/router/src/index.ts @@ -171,8 +171,12 @@ export class Router { return undefined } + // Adds the routes in `pending` to the tree. Once the tree has served a + // request, each goes in whole, as routes may no longer wait where the tree + // has grown past them. if (routes.pending.length > 0) { - build(routes) + expand(routes.root, routes.pending, 1, routes.unfiltered > 0) + routes.pending = [] } if (filter === undefined && ++routes.unfiltered >= FILTER_AFTER) { @@ -359,16 +363,6 @@ function indexStatics(routes: MethodRoutes): void { routes.indexed = indexed } -/** - * Adds the routes in `pending` to the tree. Once the tree has served a - * request, each goes in whole, as routes may no longer wait where the tree - * has grown past them. - */ -function build(routes: MethodRoutes): void { - expand(routes.root, routes.pending, 1, routes.unfiltered > 0) - routes.pending = [] -} - /** * Adds the routes waiting at `node`, which is at `start` in the split path, to * the tree, in one loop rather than a call per route, which V8 would see as