pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/nodejs/node/commit/26607a650e7a99b2e1f021c8e0864be4e8b205b4

ry-6534fbc3f5e83ac0.css" /> path: refactor path joining logic for clarity and performance · nodejs/node@26607a6 · GitHub
Skip to content

Commit 26607a6

Browse files
authored
path: refactor path joining logic for clarity and performance
PR-URL: #59781 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 9d1c9c7 commit 26607a6

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

lib/path.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
const {
2525
ArrayPrototypeIncludes,
2626
ArrayPrototypeJoin,
27+
ArrayPrototypePush,
2728
ArrayPrototypeSlice,
2829
FunctionPrototypeBind,
2930
StringPrototypeCharCodeAt,
@@ -506,22 +507,21 @@ const win32 = {
506507
if (args.length === 0)
507508
return '.';
508509

509-
let joined;
510-
let firstPart;
510+
const path = [];
511511
for (let i = 0; i < args.length; ++i) {
512512
const arg = args[i];
513513
validateString(arg, 'path');
514514
if (arg.length > 0) {
515-
if (joined === undefined)
516-
joined = firstPart = arg;
517-
else
518-
joined += `\\${arg}`;
515+
ArrayPrototypePush(path, arg);
519516
}
520517
}
521518

522-
if (joined === undefined)
519+
if (path.length === 0)
523520
return '.';
524521

522+
const firstPart = path[0];
523+
let joined = ArrayPrototypeJoin(path, '\\');
524+
525525
// Make sure that the joined path doesn't start with two slashes, because
526526
// normalize() will mistake it for a UNC path then.
527527
//

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy