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
Prev Previous commit
Reuse already-computed index
  • Loading branch information
amcasey committed May 19, 2021
commit aaaf09f8de8984b1be648f12ef3dc35236066be4
9 changes: 6 additions & 3 deletions src/compiler/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,12 @@ namespace ts {
* Normalize path separators, converting `\` into `/`.
*/
export function normalizeSlashes(path: string): string {
return path.indexOf(altDirectorySeparator) === -1
? path
: path.replace(backslashRegExp, directorySeparator);
const index = path.indexOf("\\");
if (index === -1) {
return path;
}
backslashRegExp.lastIndex = index; // prime regex with known position
return path.replace(backslashRegExp, directorySeparator);
}

/**
Expand Down