Skip to content

Commit 1f82929

Browse files
mscdexBridgeAR
authored andcommitted
path: improve normalization performance
PR-URL: #28948 Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Gus Caplan <[email protected]>
1 parent 02a50c3 commit 1f82929

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/path.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
9595
lastSegmentLength = 2;
9696
}
9797
} else {
98-
res += (res.length > 0 ? separator : '') + path.slice(lastSlash + 1, i);
98+
if (res.length > 0)
99+
res += `${separator}${path.slice(lastSlash + 1, i)}`;
100+
else
101+
res = path.slice(lastSlash + 1, i);
99102
lastSegmentLength = i - lastSlash - 1;
100103
}
101104
lastSlash = i;

0 commit comments

Comments
 (0)