@@ -133,7 +133,7 @@ namespace ts {
133133
134134 let symbolCount = 0 ;
135135 let Symbol : { new ( flags : SymbolFlags , name : string ) : Symbol } ;
136- let classifiableNames : Map < string > ;
136+ let classifiableNames : Set < string > ;
137137
138138 const unreachableFlow : FlowNode = { flags : FlowFlags . Unreachable } ;
139139 const reportedUnreachableFlow : FlowNode = { flags : FlowFlags . Unreachable } ;
@@ -147,7 +147,7 @@ namespace ts {
147147 options = opts ;
148148 languageVersion = getEmitScriptTarget ( options ) ;
149149 inStrictMode = bindInStrictMode ( file , opts ) ;
150- classifiableNames = createMap < string > ( ) ;
150+ classifiableNames = createSet ( ) ;
151151 symbolCount = 0 ;
152152 skipTransformFlagAggregation = isDeclarationFile ( file ) ;
153153
@@ -207,11 +207,11 @@ namespace ts {
207207 symbol . declarations . push ( node ) ;
208208
209209 if ( symbolFlags & SymbolFlags . HasExports && ! symbol . exports ) {
210- symbol . exports = createMap < Symbol > ( ) ;
210+ symbol . exports = createMap < string , Symbol > ( ) ;
211211 }
212212
213213 if ( symbolFlags & SymbolFlags . HasMembers && ! symbol . members ) {
214- symbol . members = createMap < Symbol > ( ) ;
214+ symbol . members = createMap < string , Symbol > ( ) ;
215215 }
216216
217217 if ( symbolFlags & SymbolFlags . Value ) {
@@ -349,17 +349,17 @@ namespace ts {
349349 // Otherwise, we'll be merging into a compatible existing symbol (for example when
350350 // you have multiple 'vars' with the same name in the same container). In this case
351351 // just add this node into the declarations list of the symbol.
352- symbol = symbolTable [ name ] || ( symbolTable [ name ] = createSymbol ( SymbolFlags . None , name ) ) ;
352+ symbol = getOrUpdate ( symbolTable , name , name => createSymbol ( SymbolFlags . None , name ) ) ;
353353
354354 if ( name && ( includes & SymbolFlags . Classifiable ) ) {
355- classifiableNames [ name ] = name ;
355+ classifiableNames . add ( name ) ;
356356 }
357357
358358 if ( symbol . flags & excludes ) {
359359 if ( symbol . isReplaceableByMethod ) {
360360 // Javascript constructor-declared symbols can be discarded in favor of
361361 // prototype symbols like methods.
362- symbol = symbolTable [ name ] = createSymbol ( SymbolFlags . None , name ) ;
362+ symbol = setAndReturn ( symbolTable , name , createSymbol ( SymbolFlags . None , name ) ) ;
363363 }
364364 else {
365365 if ( node . name ) {
@@ -484,7 +484,7 @@ namespace ts {
484484 if ( containerFlags & ContainerFlags . IsContainer ) {
485485 container = blockScopeContainer = node ;
486486 if ( containerFlags & ContainerFlags . HasLocals ) {
487- container . locals = createMap < Symbol > ( ) ;
487+ container . locals = createMap < string , Symbol > ( ) ;
488488 }
489489 addToContainerChain ( container ) ;
490490 }
@@ -1525,8 +1525,7 @@ namespace ts {
15251525
15261526 const typeLiteralSymbol = createSymbol ( SymbolFlags . TypeLiteral , "__type" ) ;
15271527 addDeclarationToSymbol ( typeLiteralSymbol , node , SymbolFlags . TypeLiteral ) ;
1528- typeLiteralSymbol . members = createMap < Symbol > ( ) ;
1529- typeLiteralSymbol . members [ symbol . name ] = symbol ;
1528+ typeLiteralSymbol . members = createMap ( [ [ symbol . name , symbol ] ] ) ;
15301529 }
15311530
15321531 function bindObjectLiteralExpression ( node : ObjectLiteralExpression ) {
@@ -1536,7 +1535,7 @@ namespace ts {
15361535 }
15371536
15381537 if ( inStrictMode ) {
1539- const seen = createMap < ElementKind > ( ) ;
1538+ const seen = createMap < string , ElementKind > ( ) ;
15401539
15411540 for ( const prop of node . properties ) {
15421541 if ( prop . name . kind !== SyntaxKind . Identifier ) {
@@ -1557,9 +1556,9 @@ namespace ts {
15571556 ? ElementKind . Property
15581557 : ElementKind . Accessor ;
15591558
1560- const existingKind = seen [ identifier . text ] ;
1559+ const existingKind = seen . get ( identifier . text ) ;
15611560 if ( ! existingKind ) {
1562- seen [ identifier . text ] = currentKind ;
1561+ seen . set ( identifier . text , currentKind ) ;
15631562 continue ;
15641563 }
15651564
@@ -1592,7 +1591,7 @@ namespace ts {
15921591 // fall through.
15931592 default :
15941593 if ( ! blockScopeContainer . locals ) {
1595- blockScopeContainer . locals = createMap < Symbol > ( ) ;
1594+ blockScopeContainer . locals = createMap < string , Symbol > ( ) ;
15961595 addToContainerChain ( blockScopeContainer ) ;
15971596 }
15981597 declareSymbol ( blockScopeContainer . locals , undefined , node , symbolFlags , symbolExcludes ) ;
@@ -2072,7 +2071,7 @@ namespace ts {
20722071 }
20732072 }
20742073
2075- file . symbol . globalExports = file . symbol . globalExports || createMap < Symbol > ( ) ;
2074+ file . symbol . globalExports = file . symbol . globalExports || createMap < string , Symbol > ( ) ;
20762075 declareSymbol ( file . symbol . globalExports , file . symbol , node , SymbolFlags . Alias , SymbolFlags . AliasExcludes ) ;
20772076 }
20782077
@@ -2119,7 +2118,7 @@ namespace ts {
21192118 Debug . assert ( isInJavaScriptFile ( node ) ) ;
21202119 // Declare a 'member' if the container is an ES5 class or ES6 constructor
21212120 if ( container . kind === SyntaxKind . FunctionDeclaration || container . kind === SyntaxKind . FunctionExpression ) {
2122- container . symbol . members = container . symbol . members || createMap < Symbol > ( ) ;
2121+ container . symbol . members = container . symbol . members || createMap < string , Symbol > ( ) ;
21232122 // It's acceptable for multiple 'this' assignments of the same identifier to occur
21242123 declareSymbol ( container . symbol . members , container . symbol , node , SymbolFlags . Property , SymbolFlags . PropertyExcludes & ~ SymbolFlags . Property ) ;
21252124 }
@@ -2151,14 +2150,14 @@ namespace ts {
21512150 constructorFunction . parent = classPrototype ;
21522151 classPrototype . parent = leftSideOfAssignment ;
21532152
2154- const funcSymbol = container . locals [ constructorFunction . text ] ;
2153+ const funcSymbol = container . locals . get ( constructorFunction . text ) ;
21552154 if ( ! funcSymbol || ! ( funcSymbol . flags & SymbolFlags . Function || isDeclarationOfFunctionExpression ( funcSymbol ) ) ) {
21562155 return ;
21572156 }
21582157
21592158 // Set up the members collection if it doesn't exist already
21602159 if ( ! funcSymbol . members ) {
2161- funcSymbol . members = createMap < Symbol > ( ) ;
2160+ funcSymbol . members = createMap < string , Symbol > ( ) ;
21622161 }
21632162
21642163 // Declare the method/property
@@ -2191,7 +2190,7 @@ namespace ts {
21912190 bindAnonymousDeclaration ( node , SymbolFlags . Class , bindingName ) ;
21922191 // Add name of class expression into the map for semantic classifier
21932192 if ( node . name ) {
2194- classifiableNames [ node . name . text ] = node . name . text ;
2193+ classifiableNames . add ( node . name . text ) ;
21952194 }
21962195 }
21972196
@@ -2207,14 +2206,15 @@ namespace ts {
22072206 // module might have an exported variable called 'prototype'. We can't allow that as
22082207 // that would clash with the built-in 'prototype' for the class.
22092208 const prototypeSymbol = createSymbol ( SymbolFlags . Property | SymbolFlags . Prototype , "prototype" ) ;
2210- if ( symbol . exports [ prototypeSymbol . name ] ) {
2209+ const symbolExport = symbol . exports . get ( prototypeSymbol . name ) ;
2210+ if ( symbolExport ) {
22112211 if ( node . name ) {
22122212 node . name . parent = node ;
22132213 }
2214- file . bindDiagnostics . push ( createDiagnosticForNode ( symbol . exports [ prototypeSymbol . name ] . declarations [ 0 ] ,
2214+ file . bindDiagnostics . push ( createDiagnosticForNode ( symbolExport . declarations [ 0 ] ,
22152215 Diagnostics . Duplicate_identifier_0 , prototypeSymbol . name ) ) ;
22162216 }
2217- symbol . exports [ prototypeSymbol . name ] = prototypeSymbol ;
2217+ symbol . exports . set ( prototypeSymbol . name , prototypeSymbol ) ;
22182218 prototypeSymbol . parent = symbol ;
22192219 }
22202220
0 commit comments