@@ -126,7 +126,7 @@ namespace ts {
126126
127127 let symbolCount = 0 ;
128128 let Symbol : { new ( flags : SymbolFlags , name : string ) : Symbol } ;
129- let classifiableNames : Map < string > ;
129+ let classifiableNames : Set < string > ;
130130
131131 const unreachableFlow : FlowNode = { flags : FlowFlags . Unreachable } ;
132132 const reportedUnreachableFlow : FlowNode = { flags : FlowFlags . Unreachable } ;
@@ -140,7 +140,7 @@ namespace ts {
140140 options = opts ;
141141 languageVersion = getEmitScriptTarget ( options ) ;
142142 inStrictMode = ! ! file . externalModuleIndicator ;
143- classifiableNames = createMap < string > ( ) ;
143+ classifiableNames = new StringSet ( ) ;
144144 symbolCount = 0 ;
145145 skipTransformFlagAggregation = isDeclarationFile ( file ) ;
146146
@@ -190,11 +190,11 @@ namespace ts {
190190 symbol . declarations . push ( node ) ;
191191
192192 if ( symbolFlags & SymbolFlags . HasExports && ! symbol . exports ) {
193- symbol . exports = createMap < Symbol > ( ) ;
193+ symbol . exports = new StringMap < Symbol > ( ) ;
194194 }
195195
196196 if ( symbolFlags & SymbolFlags . HasMembers && ! symbol . members ) {
197- symbol . members = createMap < Symbol > ( ) ;
197+ symbol . members = new StringMap < Symbol > ( ) ;
198198 }
199199
200200 if ( symbolFlags & SymbolFlags . Value ) {
@@ -332,17 +332,17 @@ namespace ts {
332332 // Otherwise, we'll be merging into a compatible existing symbol (for example when
333333 // you have multiple 'vars' with the same name in the same container). In this case
334334 // just add this node into the declarations list of the symbol.
335- symbol = symbolTable [ name ] || ( symbolTable [ name ] = createSymbol ( SymbolFlags . None , name ) ) ;
335+ symbol = getOrUpdate ( symbolTable , name , name => createSymbol ( SymbolFlags . None , name ) ) ;
336336
337337 if ( name && ( includes & SymbolFlags . Classifiable ) ) {
338- classifiableNames [ name ] = name ;
338+ classifiableNames . add ( name ) ;
339339 }
340340
341341 if ( symbol . flags & excludes ) {
342342 if ( symbol . isReplaceableByMethod ) {
343343 // Javascript constructor-declared symbols can be discarded in favor of
344344 // prototype symbols like methods.
345- symbol = symbolTable [ name ] = createSymbol ( SymbolFlags . None , name ) ;
345+ symbol = setAndReturn ( symbolTable , name , createSymbol ( SymbolFlags . None , name ) ) ;
346346 }
347347 else {
348348 if ( node . name ) {
@@ -450,7 +450,7 @@ namespace ts {
450450 if ( containerFlags & ContainerFlags . IsContainer ) {
451451 container = blockScopeContainer = node ;
452452 if ( containerFlags & ContainerFlags . HasLocals ) {
453- container . locals = createMap < Symbol > ( ) ;
453+ container . locals = new StringMap < Symbol > ( ) ;
454454 }
455455 addToContainerChain ( container ) ;
456456 }
@@ -1447,8 +1447,7 @@ namespace ts {
14471447
14481448 const typeLiteralSymbol = createSymbol ( SymbolFlags . TypeLiteral , "__type" ) ;
14491449 addDeclarationToSymbol ( typeLiteralSymbol , node , SymbolFlags . TypeLiteral ) ;
1450- typeLiteralSymbol . members = createMap < Symbol > ( ) ;
1451- typeLiteralSymbol . members [ symbol . name ] = symbol ;
1450+ typeLiteralSymbol . members = createMapWithEntry ( symbol . name , symbol ) ;
14521451 }
14531452
14541453 function bindObjectLiteralExpression ( node : ObjectLiteralExpression ) {
@@ -1458,7 +1457,7 @@ namespace ts {
14581457 }
14591458
14601459 if ( inStrictMode ) {
1461- const seen = createMap < ElementKind > ( ) ;
1460+ const seen = new StringMap < ElementKind > ( ) ;
14621461
14631462 for ( const prop of node . properties ) {
14641463 if ( prop . name . kind !== SyntaxKind . Identifier ) {
@@ -1479,9 +1478,9 @@ namespace ts {
14791478 ? ElementKind . Property
14801479 : ElementKind . Accessor ;
14811480
1482- const existingKind = seen [ identifier . text ] ;
1481+ const existingKind = seen . get ( identifier . text ) ;
14831482 if ( ! existingKind ) {
1484- seen [ identifier . text ] = currentKind ;
1483+ seen . set ( identifier . text , currentKind ) ;
14851484 continue ;
14861485 }
14871486
@@ -1514,7 +1513,7 @@ namespace ts {
15141513 // fall through.
15151514 default :
15161515 if ( ! blockScopeContainer . locals ) {
1517- blockScopeContainer . locals = createMap < Symbol > ( ) ;
1516+ blockScopeContainer . locals = new StringMap < Symbol > ( ) ;
15181517 addToContainerChain ( blockScopeContainer ) ;
15191518 }
15201519 declareSymbol ( blockScopeContainer . locals , undefined , node , symbolFlags , symbolExcludes ) ;
@@ -1976,7 +1975,7 @@ namespace ts {
19761975 }
19771976 }
19781977
1979- file . symbol . globalExports = file . symbol . globalExports || createMap < Symbol > ( ) ;
1978+ file . symbol . globalExports = file . symbol . globalExports || new StringMap < Symbol > ( ) ;
19801979 declareSymbol ( file . symbol . globalExports , file . symbol , node , SymbolFlags . Alias , SymbolFlags . AliasExcludes ) ;
19811980 }
19821981
@@ -2021,7 +2020,7 @@ namespace ts {
20212020 Debug . assert ( isInJavaScriptFile ( node ) ) ;
20222021 // Declare a 'member' if the container is an ES5 class or ES6 constructor
20232022 if ( container . kind === SyntaxKind . FunctionDeclaration || container . kind === SyntaxKind . FunctionExpression ) {
2024- container . symbol . members = container . symbol . members || createMap < Symbol > ( ) ;
2023+ container . symbol . members = container . symbol . members || new StringMap < Symbol > ( ) ;
20252024 // It's acceptable for multiple 'this' assignments of the same identifier to occur
20262025 declareSymbol ( container . symbol . members , container . symbol , node , SymbolFlags . Property , SymbolFlags . PropertyExcludes & ~ SymbolFlags . Property ) ;
20272026 }
@@ -2053,14 +2052,14 @@ namespace ts {
20532052 constructorFunction . parent = classPrototype ;
20542053 classPrototype . parent = leftSideOfAssignment ;
20552054
2056- const funcSymbol = container . locals [ constructorFunction . text ] ;
2055+ const funcSymbol = container . locals . get ( constructorFunction . text ) ;
20572056 if ( ! funcSymbol || ! ( funcSymbol . flags & SymbolFlags . Function || isDeclarationOfFunctionExpression ( funcSymbol ) ) ) {
20582057 return ;
20592058 }
20602059
20612060 // Set up the members collection if it doesn't exist already
20622061 if ( ! funcSymbol . members ) {
2063- funcSymbol . members = createMap < Symbol > ( ) ;
2062+ funcSymbol . members = new StringMap < Symbol > ( ) ;
20642063 }
20652064
20662065 // Declare the method/property
@@ -2093,7 +2092,7 @@ namespace ts {
20932092 bindAnonymousDeclaration ( node , SymbolFlags . Class , bindingName ) ;
20942093 // Add name of class expression into the map for semantic classifier
20952094 if ( node . name ) {
2096- classifiableNames [ node . name . text ] = node . name . text ;
2095+ classifiableNames . add ( node . name . text ) ;
20972096 }
20982097 }
20992098
@@ -2109,14 +2108,15 @@ namespace ts {
21092108 // module might have an exported variable called 'prototype'. We can't allow that as
21102109 // that would clash with the built-in 'prototype' for the class.
21112110 const prototypeSymbol = createSymbol ( SymbolFlags . Property | SymbolFlags . Prototype , "prototype" ) ;
2112- if ( symbol . exports [ prototypeSymbol . name ] ) {
2111+ const symbolExport = symbol . exports . get ( prototypeSymbol . name ) ;
2112+ if ( symbolExport ) {
21132113 if ( node . name ) {
21142114 node . name . parent = node ;
21152115 }
2116- file . bindDiagnostics . push ( createDiagnosticForNode ( symbol . exports [ prototypeSymbol . name ] . declarations [ 0 ] ,
2116+ file . bindDiagnostics . push ( createDiagnosticForNode ( symbolExport . declarations [ 0 ] ,
21172117 Diagnostics . Duplicate_identifier_0 , prototypeSymbol . name ) ) ;
21182118 }
2119- symbol . exports [ prototypeSymbol . name ] = prototypeSymbol ;
2119+ symbol . exports . set ( prototypeSymbol . name , prototypeSymbol ) ;
21202120 prototypeSymbol . parent = symbol ;
21212121 }
21222122
0 commit comments