Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Track cache version on BuilderState
In practice, `updateExportedFilesMapFromCache` is called repeatedly
without the cache changing in between.  When this occurs, there's no
need to update the `BuilderState` (this was already the net effect, but
it took a long time to determine that no work was required).
  • Loading branch information
amcasey committed Jul 29, 2021
commit 03bfca3b10e86dc854f5da36160ab24d103eee42
21 changes: 21 additions & 0 deletions src/compiler/builderState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ namespace ts {
*/
readonly exportedModulesMap: BuilderState.ManyToManyPathMap | undefined;

previousCache?: {
id: number,
version: number,
};

/**
* true if file version is used as signature
* This helps in delaying the calculation of the d.ts hash as version for the file till reasonable time
Expand Down Expand Up @@ -488,6 +493,22 @@ namespace ts {
export function updateExportedFilesMapFromCache(state: BuilderState, exportedModulesMapCache: ManyToManyPathMap | undefined) {
if (exportedModulesMapCache) {
Debug.assert(!!state.exportedModulesMap);

const cacheId = exportedModulesMapCache.id;
const cacheVersion = exportedModulesMapCache.version();
if (state.previousCache) {
if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) {
// If this is the same cache at the same version as last time this BuilderState
// was updated, there's not need to update again
return;
}
state.previousCache.id = cacheId;
state.previousCache.version = cacheVersion;
}
else {
state.previousCache = { id: cacheId, version: cacheVersion };
}

exportedModulesMapCache.deletedKeys()?.forEach(path => state.exportedModulesMap!.deleteKey(path));
exportedModulesMapCache.forEach((exportedModules, path) => state.exportedModulesMap!.set(path, exportedModules));
}
Expand Down