Skip to content

Commit 2b983fa

Browse files
committed
sys: Avoid array copy in getDirectories
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
1 parent 5538ffb commit 2b983fa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/compiler/sys.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ namespace ts {
16141614
}
16151615
}
16161616

1617-
function getAccessibleFileSystemEntries(path: string): FileSystemEntries {
1617+
function getAccessibleFileSystemEntries(path: string): { files: string[]; directories: string[] } {
16181618
perfLogger.logEvent("ReadDir: " + (path || "."));
16191619
try {
16201620
const entries = _fs.readdirSync(path || ".", { withFileTypes: true });
@@ -1657,7 +1657,7 @@ namespace ts {
16571657
return { files, directories };
16581658
}
16591659
catch (e) {
1660-
return emptyFileSystemEntries;
1660+
return { files: [], directories: [] };
16611661
}
16621662
}
16631663

@@ -1688,7 +1688,7 @@ namespace ts {
16881688
}
16891689

16901690
function getDirectories(path: string): string[] {
1691-
return getAccessibleFileSystemEntries(path).directories.slice();
1691+
return getAccessibleFileSystemEntries(path).directories;
16921692
}
16931693

16941694
function realpath(path: string): string {

0 commit comments

Comments
 (0)