Skip to content

Commit 5ed9e0e

Browse files
committed
Revert "Avoid no-op export map updates (#45238)"
This reverts commit 0f6e6ef.
1 parent ff1c27b commit 5ed9e0e

File tree

1 file changed

+1
-35
lines changed

1 file changed

+1
-35
lines changed

src/compiler/builderState.ts

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ namespace ts {
4848
*/
4949
readonly exportedModulesMap: BuilderState.ManyToManyPathMap | undefined;
5050

51-
previousCache?: {
52-
id: number,
53-
version: number,
54-
};
55-
5651
/**
5752
* true if file version is used as signature
5853
* This helps in delaying the calculation of the d.ts hash as version for the file till reasonable time
@@ -86,7 +81,6 @@ namespace ts {
8681
}
8782

8883
export interface ReadonlyManyToManyPathMap {
89-
readonly id: number;
9084
clone(): ManyToManyPathMap;
9185
forEach(action: (v: ReadonlySet<Path>, k: Path) => void): void;
9286
getKeys(v: Path): ReadonlySet<Path> | undefined;
@@ -103,18 +97,13 @@ namespace ts {
10397
}
10498

10599
export interface ManyToManyPathMap extends ReadonlyManyToManyPathMap {
106-
version(): number; // Incremented each time the contents are changed
107100
deleteKey(k: Path): boolean;
108101
set(k: Path, v: ReadonlySet<Path>): void;
109102
}
110103

111-
let manyToManyPathMapCount = 0;
112104
export function createManyToManyPathMap(): ManyToManyPathMap {
113105
function create(forward: ESMap<Path, ReadonlySet<Path>>, reverse: ESMap<Path, Set<Path>>, deleted: Set<Path> | undefined): ManyToManyPathMap {
114-
let version = 0;
115106
const map: ManyToManyPathMap = {
116-
id: manyToManyPathMapCount++,
117-
version: () => version,
118107
clone: () => create(new Map(forward), new Map(reverse), deleted && new Set(deleted)),
119108
forEach: fn => forward.forEach(fn),
120109
getKeys: v => reverse.get(v),
@@ -133,33 +122,26 @@ namespace ts {
133122

134123
set.forEach(v => deleteFromMultimap(reverse, v, k));
135124
forward.delete(k);
136-
version++;
137125
return true;
138126
},
139127
set: (k, vSet) => {
140-
let changed = !!deleted?.delete(k);
128+
deleted?.delete(k);
141129

142130
const existingVSet = forward.get(k);
143131
forward.set(k, vSet);
144132

145133
existingVSet?.forEach(v => {
146134
if (!vSet.has(v)) {
147-
changed = true;
148135
deleteFromMultimap(reverse, v, k);
149136
}
150137
});
151138

152139
vSet.forEach(v => {
153140
if (!existingVSet?.has(v)) {
154-
changed = true;
155141
addToMultimap(reverse, v, k);
156142
}
157143
});
158144

159-
if (changed) {
160-
version++;
161-
}
162-
163145
return map;
164146
},
165147
};
@@ -494,22 +476,6 @@ namespace ts {
494476
export function updateExportedFilesMapFromCache(state: BuilderState, exportedModulesMapCache: ManyToManyPathMap | undefined) {
495477
if (exportedModulesMapCache) {
496478
Debug.assert(!!state.exportedModulesMap);
497-
498-
const cacheId = exportedModulesMapCache.id;
499-
const cacheVersion = exportedModulesMapCache.version();
500-
if (state.previousCache) {
501-
if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) {
502-
// If this is the same cache at the same version as last time this BuilderState
503-
// was updated, there's no need to update again
504-
return;
505-
}
506-
state.previousCache.id = cacheId;
507-
state.previousCache.version = cacheVersion;
508-
}
509-
else {
510-
state.previousCache = { id: cacheId, version: cacheVersion };
511-
}
512-
513479
exportedModulesMapCache.deletedKeys()?.forEach(path => state.exportedModulesMap!.deleteKey(path));
514480
exportedModulesMapCache.forEach((exportedModules, path) => state.exportedModulesMap!.set(path, exportedModules));
515481
}

0 commit comments

Comments
 (0)