mirror of
https://github.com/honojs/hono.git
synced 2024-11-21 18:18:57 +01:00
perf(router): sort handlers by score only when necessary
This commit is contained in:
parent
44a50bdf55
commit
a6beddb34a
@ -198,10 +198,13 @@ export class Node<T> {
|
||||
|
||||
curNodes = tempNodes
|
||||
}
|
||||
const results = handlerSets.sort((a, b) => {
|
||||
return a.score - b.score
|
||||
})
|
||||
|
||||
return [results.map(({ handler, params }) => [handler, params] as [T, Params])]
|
||||
if (handlerSets.length > 1) {
|
||||
handlerSets.sort((a, b) => {
|
||||
return a.score - b.score
|
||||
})
|
||||
}
|
||||
|
||||
return [handlerSets.map(({ handler, params }) => [handler, params] as [T, Params])]
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user