Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions packages/router/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@ export class Router<T> {
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) {
Expand Down Expand Up @@ -359,16 +363,6 @@ function indexStatics<T>(routes: MethodRoutes<T>): 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<T>(routes: MethodRoutes<T>): 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
Expand Down
Loading