Skip to content

Commit 5fec688

Browse files
ahejlsbergweswigham
authored andcommitted
Use simpler singleton key and type cache for FlowAssignment nodes
1 parent ec0cbc3 commit 5fec688

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,8 @@ namespace ts {
559559
const symbolLinks: SymbolLinks[] = [];
560560
const nodeLinks: NodeLinks[] = [];
561561
const flowLoopCaches: Map<Type>[] = [];
562-
const flowAssignmentCaches: Map<Type>[] = [];
562+
const flowAssignmentKeys: string[] = [];
563+
const flowAssignmentTypes: FlowType[] = [];
563564
const flowLoopNodes: FlowNode[] = [];
564565
const flowLoopKeys: string[] = [];
565566
const flowLoopTypes: Type[][] = [];
@@ -16390,10 +16391,8 @@ namespace ts {
1639016391
const key = getOrSetCacheKey();
1639116392
if (key) {
1639216393
const id = getFlowNodeId(flow);
16393-
const cache = flowAssignmentCaches[id] || (flowAssignmentCaches[id] = createMap<Type>());
16394-
const cached = cache.get(key);
16395-
if (cached) {
16396-
return cached;
16394+
if (flowAssignmentKeys[id] === key) {
16395+
return flowAssignmentTypes[id];
1639716396
}
1639816397
}
1639916398
}
@@ -16432,8 +16431,8 @@ namespace ts {
1643216431
if (key && !isIncomplete(type)) {
1643316432
flow.flags |= FlowFlags.Cached;
1643416433
const id = getFlowNodeId(flow);
16435-
const cache = flowAssignmentCaches[id] || (flowAssignmentCaches[id] = createMap<Type>());
16436-
cache.set(key, type as Type);
16434+
flowAssignmentKeys[id] = key;
16435+
flowAssignmentTypes[id] = type;
1643716436
}
1643816437
}
1643916438
}

0 commit comments

Comments
 (0)