Skip to content

Commit eb5408e

Browse files
committed
Kick out of normalizePath if there's nothing to do
...using `relativePathSegmentRegExp`. Bonus: use a regex to handle "/./" to avoid splitting and joining in a common case. When building the compiler, for example, it looks like ~95% of arguments to `normalizePath` do not require any normalization.
1 parent 14343be commit eb5408e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/compiler/path.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,10 @@ namespace ts {
552552

553553
export function normalizePath(path: string): string {
554554
path = normalizeSlashes(path);
555+
path = path.replace(/\/\.\//g, "/");
556+
if (!relativePathSegmentRegExp.test(path)) {
557+
return path;
558+
}
555559
const normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
556560
return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
557561
}

0 commit comments

Comments
 (0)