Conversation
If a posix path contains no '.' and no '//', it has no '.'/'..' segments and no empty segments, so the result is the input. Official benchmark/path/normalize-posix.js: /foo/bar is about 66% faster and /foo is about 31% faster. Paths that still need normalizeString are slightly slower because of the two indexOf probes. Assisted-by: a closed-source coding agent Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com> Co-authored-by: Yagiz Nizipli <anonrig@users.noreply.github.com>
Collaborator
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #66177 +/- ##
==========================================
+ Coverage 90.27% 90.28% +0.01%
==========================================
Files 790 790
Lines 271651 272049 +398
Branches 51842 51949 +107
==========================================
+ Hits 245228 245618 +390
- Misses 16928 16934 +6
- Partials 9495 9497 +2
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a posix path contains no
'.'and no'//', it has no'.'/'..'segments and no empty segments, sopath.posix.normalize()can return the input without runningnormalizeString().This change was implemented with assistance from a closed-source coding agent. I verified the source, official
benchmark/path/normalize-posix.jsresults, andtest-path-normalize.js.Official benches
Three-run medians,
n=1e5:/foo/bar/foo/foo/bar//baz/asdf/quux/..Already-normalized paths (the common case) skip the segment walk. Paths that still need
normalizeString()pay twoindexOfprobes.Tests
test-path-normalize.js,test-path.js,test-path-join.js,test-path-resolve.js.