Skip to content
Merged
Changes from 1 commit
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
Next Next commit
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.
  • Loading branch information
amcasey committed May 14, 2021
commit 0c797a55dab2ce3539fe8602e217fc22a8d3f624
4 changes: 3 additions & 1 deletion src/compiler/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,9 @@ namespace ts {
* Normalize path separators, converting `\` into `/`.
*/
export function normalizeSlashes(path: string): string {
return path.replace(backslashRegExp, directorySeparator);
return path.indexOf(altDirectorySeparator) === -1
? path
: path.replace(backslashRegExp, directorySeparator);
}

/**
Expand Down