back

by bikeshaving·5y ago·view on hn ↗
The benefit of doing “O(n) routing” is that you don’t have to do complicated things so that a certain route gets more precedence. Real websites often have legacy URLs or one-off URLs for marketing, and being able to give these routes higher precedence by placing them higher in the route list is just easier. It’s also easier to reason about the router testing each route in sequence rather than attempting to understand how it assigned priority based on some leaky heuristics.

> if you are using this sort of flexibility your URL structure is too confusing anyways

A lot of the time, we don’t have a say in URL structure, unless we’re happy to break old URLs all the time.

Also, can we not use Big-O notation for quantities which never break 10,000, let alone 1,000. The cost of checking all the routes in order is going to be negligible.