Skip to content

Commit 8ea9502

Browse files
committed
Make a map for semantic diagnostics from old state
1 parent 51837bb commit 8ea9502

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/compiler/builder.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace ts {
4141
/**
4242
* True if the semantic diagnostics were copied from the old state
4343
*/
44-
semanticDiagnosticsFromOldStateFiles?: number;
44+
semanticDiagnosticsFromOldState?: Map<true>;
4545
/**
4646
* program corresponding to this state
4747
*/
@@ -104,7 +104,10 @@ namespace ts {
104104
const diagnostics = oldState!.semanticDiagnosticsPerFile!.get(sourceFilePath);
105105
if (diagnostics) {
106106
state.semanticDiagnosticsPerFile!.set(sourceFilePath, diagnostics);
107-
state.semanticDiagnosticsFromOldStateFiles = (state.semanticDiagnosticsFromOldStateFiles || 0) + 1;
107+
if (!state.semanticDiagnosticsFromOldState) {
108+
state.semanticDiagnosticsFromOldState = createMap<true>();
109+
}
110+
state.semanticDiagnosticsFromOldState.set(sourceFilePath, true);
108111
}
109112
}
110113
});
@@ -184,13 +187,8 @@ namespace ts {
184187
* Remove the semantic diagnostics cached from old state for affected File and the files that are referencing modules that export entities from affected file
185188
*/
186189
function cleanSemanticDiagnosticsOfAffectedFile(state: BuilderProgramState, affectedFile: SourceFile) {
187-
if (!state.semanticDiagnosticsFromOldStateFiles) {
188-
Debug.assert(!state.semanticDiagnosticsPerFile!.has(affectedFile.path));
189-
return;
190-
}
191-
192190
if (removeSemanticDiagnosticsOf(state, affectedFile.path)) {
193-
// If there are no more diagnostics from old cache, remove them
191+
// If there are no more diagnostics from old cache, done
194192
return;
195193
}
196194

@@ -235,12 +233,12 @@ namespace ts {
235233
* returns true if there are no more semantic diagnostics from the old state
236234
*/
237235
function removeSemanticDiagnosticsOf(state: BuilderProgramState, path: Path) {
238-
if (state.semanticDiagnosticsPerFile!.delete(path)) {
239-
Debug.assert((state.semanticDiagnosticsFromOldStateFiles || 0) > 0);
240-
state.semanticDiagnosticsFromOldStateFiles!--;
241-
return !state.semanticDiagnosticsFromOldStateFiles;
236+
if (!state.semanticDiagnosticsFromOldState) {
237+
return false;
242238
}
243-
return false;
239+
state.semanticDiagnosticsFromOldState.delete(path);
240+
state.semanticDiagnosticsPerFile!.delete(path);
241+
return !state.semanticDiagnosticsFromOldState.size;
244242
}
245243

246244
/**

0 commit comments

Comments
 (0)