Skip to content

Matcher is linear and uses too much regex #3708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iurisilvio opened this issue Jan 30, 2022 · 1 comment
Closed

Matcher is linear and uses too much regex #3708

iurisilvio opened this issue Jan 30, 2022 · 1 comment

Comments

@iurisilvio
Copy link
Contributor

The matcher implementation always use path-to-regex lib. It is too much for static paths, where it is possible to just compare strings.

Also, the implementatioin is O(N), if you have 100 routes and want to match the last one (that is static), you run 100 regex tests.
Regex is around ~10x slower than a simple string match and with a lookup table it is O(1).

for (let i = 0; i < pathList.length; i++) {
const path = pathList[i]
const record = pathMap[path]
if (matchRoute(record.regex, location.path, location.params)) {
return _createRoute(record, location, redirectedFrom)

I did the PR #3707 with a draft of my idea.

@vue-bot
Copy link

vue-bot commented Jan 30, 2022

Hello, thank you for taking time filling this issue!

However, we kindly ask you to use our Issue Helper when creating new issues, in order to ensure every issue provides the necessary information for us to investigate. This explains why your issue has been automatically closed by me (your robot friend!).

I hope to see your helper-created issue very soon!

@vue-bot vue-bot closed this as completed Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants