Skip to content
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

improve removeDuplicateSlashes #318

Open
Uzlopak opened this issue Feb 8, 2023 · 1 comment
Open

improve removeDuplicateSlashes #318

Uzlopak opened this issue Feb 8, 2023 · 1 comment

Comments

@Uzlopak
Copy link
Contributor

Uzlopak commented Feb 8, 2023

If we replace the current implementation of removeDuplicateSlashes with the following:

const RemoveDuplicateSlashesRE = /\/\/+/g
function removeDuplicateSlashes (path) {
  return (path.indexOf('//') === -1 && path) || path.replace(RemoveDuplicateSlashesRE, '/')
}

then the case withoout duplicate slashes gets from about 4,284,328 ops/sec up to 5,419,257 ops/sec. The case that we have some duplicate slashes goes from 2,483,375 ops/sec to 2,292,004 ops/sec.

@ivan-tymoshenko
Copy link
Collaborator

Looks like it's worth it. Go for it.

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