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

feat: add supportWindowsPaths option #476

Closed
wants to merge 1 commit into from

Conversation

nicolas377
Copy link

This is the second and last part of the implementation of #468. The PR implements the supportWindowsPaths option, which is intended to be a flip-on switch for automatic backslash coercion.

closes #468

self.supportWindowsPaths = !!options.supportWindowsPaths
if (self.supportWindowsPaths) {
options.pathSep = undefined
pattern = pattern.replace(/\\/g, "/")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool things I found out, /\\/g is 105% faster than /\\|\//g.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So instead of doing 1000/ms you can do 2000? Not trying to be too snarky, but it's a one-time action at initialization, and wildly fast, even in a benchmark with 2000 path portions and a mix of \ and /. Even if it was 10,000x faster, even if it was somehow able to magically do it in 0 CPU cycles, it's still only saving you 0.0001% of the overall time.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, if it was actually possible to do in 0 CPU cycles, we'd be better off spending our time figuring how how to express all compute problems in terms of slash replacement, and win the turing prize for solving P=NP lol

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that it's a very minor improvement in the grand scheme of things, it just seemed pretty cool to me.

@isaacs
Copy link
Owner

isaacs commented Mar 1, 2023

This landed as windowsPathsNoEscape some time ago.

@isaacs isaacs closed this Mar 1, 2023
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

Successfully merging this pull request may close these issues.

feat: coerce all paths to forward slashes as a config option
2 participants