solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.1k stars 137 forks source link

Slow performance matching route with localeCompare #406

Open chiefcll opened 2 months ago

chiefcll commented 2 months ago

Describe the bug

Matching a segment is taking ~45 ms due to localeCompare. This only happens when deep linking - the base route doesn't have an issue.

image

Your Example Website or App

https://lightning-js.github.io/solid-demo-app/#/browse/movie

Steps to Reproduce the Bug or Issue

Load up the site with 6x slowdown in Chrome - doing the initial match for a route takes ~45ms.

image

Expected behavior

Much faster matching of routes. https://stackoverflow.com/questions/14677060/400x-sorting-speedup-by-switching-a-localecompareb-to-ab-1ab10 Recommend not using localeCompare

Screenshots or Videos

No response

Platform

Mac, Chrome, latest

Additional context

No response

ryansolid commented 2 months ago

I'd definitely be open to this. Have you tried this switch yourself in your app?

chiefcll commented 2 months ago

I haven't tried changing it yet. I assume using normal string comparison is much faster - but some users may need localeCompare. Probably need an option to use one or the other based on if the user needs it - but I assume large percentage of users don't need localeCompare for routing.