Skip to content

Commit 01aec72

Browse files
committed
sys: Avoid array copy in getDirectories
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent bee7ee0 commit 01aec72

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
@@ -1350,7 +1350,7 @@ namespace ts {
13501350
}
13511351
}
13521352

1353-
function getAccessibleFileSystemEntries(path: string): FileSystemEntries {
1353+
function getAccessibleFileSystemEntries(path: string): { files: string[]; directories: string[] } {
13541354
perfLogger.logEvent("ReadDir: " + (path || "."));
13551355
try {
13561356
const entries = _fs.readdirSync(path || ".", { withFileTypes: true });
@@ -1393,7 +1393,7 @@ namespace ts {
13931393
return { files, directories };
13941394
}
13951395
catch (e) {
1396-
return emptyFileSystemEntries;
1396+
return { files: [], directories: [] };
13971397
}
13981398
}
13991399

@@ -1424,7 +1424,7 @@ namespace ts {
14241424
}
14251425

14261426
function getDirectories(path: string): string[] {
1427-
return getAccessibleFileSystemEntries(path).directories.slice();
1427+
return getAccessibleFileSystemEntries(path).directories;
14281428
}
14291429

14301430
function realpath(path: string): string {

0 commit comments

Comments
 (0)