fridays / next-routes

Universal dynamic routes for Next.js
MIT License
2.47k stars 230 forks source link

Performance: use .some() instead of .reduce()? #131

Closed oliviertassinari closed 1 year ago

oliviertassinari commented 6 years ago

I don't think that we need to loop through all the registered routes: https://github.com/fridays/next-routes/blob/193f2a38605b03895f6bf9c23c65f72c0338d5c8/src/index.js#L51

fridays commented 6 years ago

You're right we could return earlier when a route was found. We used .find in the past but people had problems in IE. Maybe a for loop with early return would be best