Skip to content

Commit 0c797a5

Browse files
committed
Make normalizeSlashes a no-op there are no bad slashes
On Windows, there will probably be a negligible slowdown, iterating over the pre-slash prefix of each unnormalized path (though we might come out ahead if paths are normalized more than once). On *nix, this saves work - 1.8s -> 0.4s in the project I'm investigating.
1 parent f414d13 commit 0c797a5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/compiler/path.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,9 @@ namespace ts {
452452
* Normalize path separators, converting `\` into `/`.
453453
*/
454454
export function normalizeSlashes(path: string): string {
455-
return path.replace(backslashRegExp, directorySeparator);
455+
return path.indexOf(altDirectorySeparator) === -1
456+
? path
457+
: path.replace(backslashRegExp, directorySeparator);
456458
}
457459

458460
/**

0 commit comments

Comments
 (0)