Skip to content

Commit bd06e77

Browse files
Addressed code review feedback.
1 parent 6f563b7 commit bd06e77

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/compiler/tc.ts

+7-10
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,10 @@ module ts {
277277
// specified since the last compilation cycle.
278278
removeWatchers(program);
279279

280-
// Gets us syntactically correct files from the last compilation.
281-
var oldSourceFiles = arrayToMap(program.getSourceFiles(), file => getCanonicalName(file.filename));
282-
283-
// No longer using the old program.
284-
program = undefined;
280+
// Reuse source files from the last compilation so long as they weren't changed.
281+
var oldSourceFiles = arrayToMap(
282+
filter(program.getSourceFiles(), file => !hasProperty(changedFiles, getCanonicalName(file.filename))),
283+
file => getCanonicalName(file.filename));
285284

286285
// We create a new compiler host for this compilation cycle.
287286
// This new host is effectively the same except that 'getSourceFile'
@@ -291,11 +290,9 @@ module ts {
291290
newCompilerHost.getSourceFile = (fileName, languageVersion, onError) => {
292291
fileName = getCanonicalName(fileName);
293292

294-
if (!hasProperty(changedFiles, fileName)) {
295-
var sourceFile = lookUp(oldSourceFiles, fileName);
296-
if (sourceFile) {
297-
return sourceFile;
298-
}
293+
var sourceFile = lookUp(oldSourceFiles, fileName);
294+
if (sourceFile) {
295+
return sourceFile;
299296
}
300297

301298
return compilerHost.getSourceFile(fileName, languageVersion, onError);

0 commit comments

Comments
 (0)