Skip to content

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

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
RafaelGSS:avoid-building-error-label-per-argument-in-resolve
Nov 23, 2026
Merged

nodejs-github-bot merged 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 758 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

@gurgunday gurgunday left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@RafaelGSS RafaelGSS added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 9, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 9, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

nodejs-github-bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Comment thread lib/path.js
validateString(path, `paths[${i}]`);
if (typeof path !== 'string') {
throw new ERR_INVALID_ARG_TYPE(`paths[${i}]`, 'string', path);
}

@jasnell jasnell Nov 22, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: longer term, I wonder if it would be better to have a variation of validateString that formats... validateString(path, 'paths[%s]', i);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Possibly that's a good choice yes.

@RafaelGSS RafaelGSS added author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue PRs queued for automated landing through the Commit Queue. labels Nov 23, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 1a8cf16 into nodejs:main Nov 23, 2026
84 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 1a8cf16

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 23, 2026
aduh95 pushed a commit that referenced this pull request Nov 24, 2026
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
PR-URL: #66616
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. 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.

5 participants