solid-router icon indicating copy to clipboard operation
solid-router copied to clipboard

Slow performance matching route with localeCompare

Open chiefcll opened this issue 1 year ago • 2 comments

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

chiefcll avatar Apr 16 '24 01:04 chiefcll

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

ryansolid avatar Apr 29 '24 20:04 ryansolid

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.

chiefcll avatar May 04 '24 15:05 chiefcll