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

path: remove unnecessary string copies #14438

Closed
wants to merge 5 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ const win32 = {
if (len === 3) {
// `path` contains just a drive root, exit early to avoid
// unnecessary work
ret.root = ret.dir = path.slice(0, 3);
ret.root = ret.dir = path;
return ret;
}
isAbsolute = true;
Expand All @@ -1049,7 +1049,7 @@ const win32 = {
} else {
// `path` contains just a drive root, exit early to avoid
// unnecessary work
ret.root = ret.dir = path.slice(0, 2);
ret.root = ret.dir = path;
return ret;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

The

       ret.root = ret.dir = path[0];

below can be simplified to

       ret.root = ret.dir = path;

as well, AFAICT.

Copy link
Contributor

Choose a reason for hiding this comment

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

Anyway could you add a comment // `(len <= 1)`

Expand Down