From 19a222e7185ad69d16573efba538823409dbd33b Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 23 Oct 2015 13:09:05 -0700 Subject: [PATCH] addressed PR feedback --- src/compiler/tsc.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index a72b5bb1b06..dd0f9246d05 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -159,6 +159,8 @@ namespace ts { let timerHandleForRecompilation: number; // Handle for 0.25s wait timer to trigger recompilation let timerHandleForDirectoryChanges: number; // Handle for 0.25s wait timer to trigger directory change handler + // This map stores and reuses results of fileExists check that happen inside 'createProgram' + // This allows to save time in module resolution heavy scenarios when existence of the same file might be checked multiple times. let cachedExistingFiles: Map; let hostFileExists: typeof compilerHost.fileExists; @@ -279,7 +281,7 @@ namespace ts { compilerHost.getSourceFile = getSourceFile; hostFileExists = compilerHost.fileExists; - compilerHost.fileExists = fileExists; + compilerHost.fileExists = cachedFileExists; } // reset the cache of existing files @@ -295,7 +297,7 @@ namespace ts { reportWatchDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); } - function fileExists(fileName: string): boolean { + function cachedFileExists(fileName: string): boolean { if (hasProperty(cachedExistingFiles, fileName)) { return cachedExistingFiles[fileName]; }