File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3869,14 +3869,13 @@ module ts {
38693869 // If this type has already been instantiated using this mapper, returned the cached result. This guards against
38703870 // infinite instantiations of cyclic types, e.g. "var x: { a: T, b: typeof x };"
38713871 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;
38763875 }
38773876 }
38783877 else {
3879- mapper.mappings = [] ;
3878+ mapper.mappings = {} ;
38803879 }
38813880 // Instantiate the given type using the given mapper and cache the result
38823881 let result = <ResolvedType>createObjectType(TypeFlags.Anonymous, type.symbol);
@@ -3888,7 +3887,7 @@ module ts {
38883887 let numberIndexType = getIndexTypeOfType(type, IndexKind.Number);
38893888 if (stringIndexType) result.stringIndexType = instantiateType(stringIndexType, mapper);
38903889 if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper);
3891- mapper.mappings.push({ type, result }) ;
3890+ mapper.mappings[type.id] = result;
38923891 return result;
38933892 }
38943893
Original file line number Diff line number Diff line change @@ -1586,15 +1586,10 @@ module ts {
15861586 Number ,
15871587 }
15881588
1589- export interface TypeMapping {
1590- type : Type ;
1591- result : Type ;
1592- }
1593-
15941589 /* @internal */
15951590 export interface TypeMapper {
15961591 ( t : TypeParameter ) : Type ;
1597- mappings ?: TypeMapping [ ] ; // Type mapping cache
1592+ mappings ?: Map < Type > ; // Type mapping cache
15981593 }
15991594
16001595 /* @internal */
You can’t perform that action at this time.
0 commit comments