Merge pull request #40444 from amcasey/Cherry40043

Set stackTraceLimit to 0 in fileSystemEntryExists
This commit is contained in:
Andrew Casey
2020-09-16 12:50:57 -07:00
committed by GitHub

View File

@@ -1662,6 +1662,11 @@ namespace ts {
}
function fileSystemEntryExists(path: string, entryKind: FileSystemEntryKind): boolean {
// Since the error thrown by fs.statSync isn't used, we can avoid collecting a stack trace to improve
// the CPU time performance.
const originalStackTraceLimit = Error.stackTraceLimit;
Error.stackTraceLimit = 0;
try {
const stat = _fs.statSync(path);
switch (entryKind) {
@@ -1673,6 +1678,9 @@ namespace ts {
catch (e) {
return false;
}
finally {
Error.stackTraceLimit = originalStackTraceLimit;
}
}
function fileExists(path: string): boolean {