Skip to content

Commit

Permalink
Merge pull request #40444 from amcasey/Cherry40043
Browse files Browse the repository at this point in the history
Set stackTraceLimit to 0 in fileSystemEntryExists
  • Loading branch information
amcasey committed Sep 16, 2020
2 parents 65b84e7 + 657576a commit 23c77c4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/compiler/sys.ts
Expand Up @@ -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) {
Expand All @@ -1673,6 +1678,9 @@ namespace ts {
catch (e) {
return false;
}
finally {
Error.stackTraceLimit = originalStackTraceLimit;
}
}

function fileExists(path: string): boolean {
Expand Down

0 comments on commit 23c77c4

Please sign in to comment.