logoalt Hacker News

tshaddoxyesterday at 9:40 PM0 repliesview on HN

It would take a very large number of routes before linear search would become a noticeable performance problem.

At that point, you’d probably be splitting the router itself into multiple client bundles, with something at the root to quickly match the URL with a bundle of routes (maybe a hash table on the first URL segment, or even a trie).

This URLPattern library and linear search would still be a reasonable choice for implementing each individual route bundle. And in practice, just do it the naive way until it actually becomes a problem.