File tree Expand file tree Collapse file tree 2 files changed +6
-12
lines changed Expand file tree Collapse file tree 2 files changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -3869,14 +3869,13 @@ module ts {
3869
3869
// If this type has already been instantiated using this mapper, returned the cached result. This guards against
3870
3870
// infinite instantiations of cyclic types, e.g. "var x: { a: T, b: typeof x };"
3871
3871
if (mapper.mappings) {
3872
- for (let mapping of mapper.mappings) {
3873
- if (mapping.type === type) {
3874
- return mapping.result;
3875
- }
3872
+ let cached = <ObjectType>mapper.mappings[type.id];
3873
+ if (cached) {
3874
+ return cached;
3876
3875
}
3877
3876
}
3878
3877
else {
3879
- mapper.mappings = [] ;
3878
+ mapper.mappings = {} ;
3880
3879
}
3881
3880
// Instantiate the given type using the given mapper and cache the result
3882
3881
let result = <ResolvedType>createObjectType(TypeFlags.Anonymous, type.symbol);
@@ -3888,7 +3887,7 @@ module ts {
3888
3887
let numberIndexType = getIndexTypeOfType(type, IndexKind.Number);
3889
3888
if (stringIndexType) result.stringIndexType = instantiateType(stringIndexType, mapper);
3890
3889
if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper);
3891
- mapper.mappings.push({ type, result }) ;
3890
+ mapper.mappings[type.id] = result;
3892
3891
return result;
3893
3892
}
3894
3893
Original file line number Diff line number Diff line change @@ -1586,15 +1586,10 @@ module ts {
1586
1586
Number ,
1587
1587
}
1588
1588
1589
- export interface TypeMapping {
1590
- type : Type ;
1591
- result : Type ;
1592
- }
1593
-
1594
1589
/* @internal */
1595
1590
export interface TypeMapper {
1596
1591
( t : TypeParameter ) : Type ;
1597
- mappings ?: TypeMapping [ ] ; // Type mapping cache
1592
+ mappings ?: Map < Type > ; // Type mapping cache
1598
1593
}
1599
1594
1600
1595
/* @internal */
You can’t perform that action at this time.
0 commit comments