Skip to content

path: avoid building error label per argument in resolve - #66616

Open
RafaelGSS wants to merge 1 commit into
nodejs:mainfrom
RafaelGSS:avoid-building-error-label-per-argument-in-resolve
Open

RafaelGSS wants to merge 1 commit into
nodejs:mainfrom
RafaelGSS:avoid-building-error-label-per-argument-in-resolve

Conversation

@RafaelGSS

@RafaelGSS RafaelGSS commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

path: avoid building error label per argument in resolve

This inlines the typeof check and only builds the label in the error path, the same pattern validateStringArray() already uses.

Benchmark (benchmark/compare.js, 30 runs, Linux x64):

                                                                                   confidence improvement
path/resolve-posix.js n=100000 paths=''                                                  ***     12.55 %
path/resolve-posix.js n=100000 paths='.'                                                  **      5.48 %
path/resolve-posix.js n=100000 paths='/a/b/c/|abc'                                       ***      7.83 %
path/resolve-posix.js n=100000 paths='a/b/c/|../../..'                                    **      2.30 %
path/resolve-posix.js n=100000 paths='empty'                                                      1.78 %
path/resolve-posix.js n=100000 paths='foo/bar|/tmp/file/|..|a/../subfile'                ***      6.03 %
path/resolve-posix.js n=100000 paths='|'                                                 ***      4.29 %
path/resolve-win32.js n=100000 paths=''                                                   **      4.73 %
path/resolve-win32.js n=100000 paths='.'                                                          1.51 %
path/resolve-win32.js n=100000 paths='c:/blah\\blah|d:/games|c:../a'                      **      3.66 %
path/resolve-win32.js n=100000 paths='c:/ignore|d:\\a/b\\c/d|\\e.exe'                    ***      7.81 %
path/resolve-win32.js n=100000 paths='empty'                                                     -0.02 %
path/resolve-win32.js n=100000 paths='|'                                                   *      3.21 %
path/relative-posix.js n=100000 paths='/data/orandea/test/aaa|/data/orandea/impl/bbb'    ***     -3.35 %
path/relative-posix.js n=100000 paths='/foo/bar/baz/quux|/'                                       1.02 %
path/relative-posix.js n=100000 paths='/foo/bar/baz/quux|/foo/bar/baz/quux'                      -2.30 %
path/relative-posix.js n=100000 paths='/foo/bar/baz/quux|/var/log'                                1.12 %
path/relative-posix.js n=100000 paths='/var|/bin'                                                 0.64 %
path/relative-posix.js n=100000 paths='/|/'                                                      -0.54 %
path/relative-posix.js n=100000 paths='/|/var'                                                   -0.13 %
path/relative-win32.js n=100000 paths='C:\\foo\\BAR\\BAZ|C:\\foo\\bar\\baz'                       0.62 %
path/relative-win32.js n=100000 paths='C:\\foo\\bar\\baz\\quux|C:\\'                              1.26 %
path/relative-win32.js n=100000 paths='C:\\foo\\bar\\baz|C:\\foo\\bar\\baz'                      -3.67 %
path/relative-win32.js n=100000 paths='C:\\orandea\\test\\aaa|C:\\orandea\\impl\\bbb'             0.36 %
path/relative-win32.js n=100000 paths='C:\\|D:\\'                                                 0.50 %
path/relative-win32.js n=100000 paths='c:\\İ\\a\\İ|c:\\İ\\b\\İ\\test.txt|..\\..\\b\\İ\\test.txt'   *      1.40 %

Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/path

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. path Issues and PRs related to the path subsystem. labels Oct 8, 2026
@RafaelGSS RafaelGSS added the performance Issues and PRs related to the performance of Node.js. label Oct 8, 2026
@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.43%. Comparing base (f9defa6) to head (6069640).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66616      +/-   ##
==========================================
- Coverage   90.43%   90.43%   -0.01%     
==========================================
  Files         791      791              
  Lines      276563   276594      +31     
  Branches    53115    53115              
==========================================
+ Hits       250117   250138      +21     
- Misses      16850    16863      +13     
+ Partials     9596     9593       -3     
Files with missing lines Coverage Δ
lib/path.js 97.55% <100.00%> (+0.07%) ⬆️

... and 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@RafaelGSS

Copy link
Copy Markdown
Member Author

PTAL @nodejs/performance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. path Issues and PRs related to the path subsystem. performance Issues and PRs related to the performance of Node.js.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants