unjs / rou3

🌳 Lightweight and fast rou(ter) for JavaScript
MIT License
442 stars 16 forks source link

perf!(findRoute): return first result #122

Closed pi0 closed 2 months ago

pi0 commented 2 months ago

Internally we store an array of matches because with matchAll, it is possible to match /foo/:bar + /foo/:baz (same method) but for purpose of routing only one route is meaningful to be matchable.

This PR increases perf by %12-17 by avoiding array creation (and also honestly, the DX)