@@ -126,7 +126,7 @@ namespace ts {
126
126
127
127
let symbolCount = 0 ;
128
128
let Symbol : { new ( flags : SymbolFlags , name : string ) : Symbol } ;
129
- let classifiableNames : Map < string > ;
129
+ let classifiableNames : Set < string > ;
130
130
131
131
const unreachableFlow : FlowNode = { flags : FlowFlags . Unreachable } ;
132
132
const reportedUnreachableFlow : FlowNode = { flags : FlowFlags . Unreachable } ;
@@ -140,7 +140,7 @@ namespace ts {
140
140
options = opts ;
141
141
languageVersion = getEmitScriptTarget ( options ) ;
142
142
inStrictMode = ! ! file . externalModuleIndicator ;
143
- classifiableNames = createMap < string > ( ) ;
143
+ classifiableNames = new StringSet ( ) ;
144
144
symbolCount = 0 ;
145
145
skipTransformFlagAggregation = isDeclarationFile ( file ) ;
146
146
@@ -190,11 +190,11 @@ namespace ts {
190
190
symbol . declarations . push ( node ) ;
191
191
192
192
if ( symbolFlags & SymbolFlags . HasExports && ! symbol . exports ) {
193
- symbol . exports = createMap < Symbol > ( ) ;
193
+ symbol . exports = new StringMap < Symbol > ( ) ;
194
194
}
195
195
196
196
if ( symbolFlags & SymbolFlags . HasMembers && ! symbol . members ) {
197
- symbol . members = createMap < Symbol > ( ) ;
197
+ symbol . members = new StringMap < Symbol > ( ) ;
198
198
}
199
199
200
200
if ( symbolFlags & SymbolFlags . Value ) {
@@ -332,17 +332,17 @@ namespace ts {
332
332
// Otherwise, we'll be merging into a compatible existing symbol (for example when
333
333
// you have multiple 'vars' with the same name in the same container). In this case
334
334
// 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 ) ) ;
336
336
337
337
if ( name && ( includes & SymbolFlags . Classifiable ) ) {
338
- classifiableNames [ name ] = name ;
338
+ classifiableNames . add ( name ) ;
339
339
}
340
340
341
341
if ( symbol . flags & excludes ) {
342
342
if ( symbol . isReplaceableByMethod ) {
343
343
// Javascript constructor-declared symbols can be discarded in favor of
344
344
// prototype symbols like methods.
345
- symbol = symbolTable [ name ] = createSymbol ( SymbolFlags . None , name ) ;
345
+ symbol = setAndReturn ( symbolTable , name , createSymbol ( SymbolFlags . None , name ) ) ;
346
346
}
347
347
else {
348
348
if ( node . name ) {
@@ -450,7 +450,7 @@ namespace ts {
450
450
if ( containerFlags & ContainerFlags . IsContainer ) {
451
451
container = blockScopeContainer = node ;
452
452
if ( containerFlags & ContainerFlags . HasLocals ) {
453
- container . locals = createMap < Symbol > ( ) ;
453
+ container . locals = new StringMap < Symbol > ( ) ;
454
454
}
455
455
addToContainerChain ( container ) ;
456
456
}
@@ -1447,8 +1447,7 @@ namespace ts {
1447
1447
1448
1448
const typeLiteralSymbol = createSymbol ( SymbolFlags . TypeLiteral , "__type" ) ;
1449
1449
addDeclarationToSymbol ( typeLiteralSymbol , node , SymbolFlags . TypeLiteral ) ;
1450
- typeLiteralSymbol . members = createMap < Symbol > ( ) ;
1451
- typeLiteralSymbol . members [ symbol . name ] = symbol ;
1450
+ typeLiteralSymbol . members = createMapWithEntry ( symbol . name , symbol ) ;
1452
1451
}
1453
1452
1454
1453
function bindObjectLiteralExpression ( node : ObjectLiteralExpression ) {
@@ -1458,7 +1457,7 @@ namespace ts {
1458
1457
}
1459
1458
1460
1459
if ( inStrictMode ) {
1461
- const seen = createMap < ElementKind > ( ) ;
1460
+ const seen = new StringMap < ElementKind > ( ) ;
1462
1461
1463
1462
for ( const prop of node . properties ) {
1464
1463
if ( prop . name . kind !== SyntaxKind . Identifier ) {
@@ -1479,9 +1478,9 @@ namespace ts {
1479
1478
? ElementKind . Property
1480
1479
: ElementKind . Accessor ;
1481
1480
1482
- const existingKind = seen [ identifier . text ] ;
1481
+ const existingKind = seen . get ( identifier . text ) ;
1483
1482
if ( ! existingKind ) {
1484
- seen [ identifier . text ] = currentKind ;
1483
+ seen . set ( identifier . text , currentKind ) ;
1485
1484
continue ;
1486
1485
}
1487
1486
@@ -1514,7 +1513,7 @@ namespace ts {
1514
1513
// fall through.
1515
1514
default :
1516
1515
if ( ! blockScopeContainer . locals ) {
1517
- blockScopeContainer . locals = createMap < Symbol > ( ) ;
1516
+ blockScopeContainer . locals = new StringMap < Symbol > ( ) ;
1518
1517
addToContainerChain ( blockScopeContainer ) ;
1519
1518
}
1520
1519
declareSymbol ( blockScopeContainer . locals , undefined , node , symbolFlags , symbolExcludes ) ;
@@ -1976,7 +1975,7 @@ namespace ts {
1976
1975
}
1977
1976
}
1978
1977
1979
- file . symbol . globalExports = file . symbol . globalExports || createMap < Symbol > ( ) ;
1978
+ file . symbol . globalExports = file . symbol . globalExports || new StringMap < Symbol > ( ) ;
1980
1979
declareSymbol ( file . symbol . globalExports , file . symbol , node , SymbolFlags . Alias , SymbolFlags . AliasExcludes ) ;
1981
1980
}
1982
1981
@@ -2021,7 +2020,7 @@ namespace ts {
2021
2020
Debug . assert ( isInJavaScriptFile ( node ) ) ;
2022
2021
// Declare a 'member' if the container is an ES5 class or ES6 constructor
2023
2022
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 > ( ) ;
2025
2024
// It's acceptable for multiple 'this' assignments of the same identifier to occur
2026
2025
declareSymbol ( container . symbol . members , container . symbol , node , SymbolFlags . Property , SymbolFlags . PropertyExcludes & ~ SymbolFlags . Property ) ;
2027
2026
}
@@ -2053,14 +2052,14 @@ namespace ts {
2053
2052
constructorFunction . parent = classPrototype ;
2054
2053
classPrototype . parent = leftSideOfAssignment ;
2055
2054
2056
- const funcSymbol = container . locals [ constructorFunction . text ] ;
2055
+ const funcSymbol = container . locals . get ( constructorFunction . text ) ;
2057
2056
if ( ! funcSymbol || ! ( funcSymbol . flags & SymbolFlags . Function || isDeclarationOfFunctionExpression ( funcSymbol ) ) ) {
2058
2057
return ;
2059
2058
}
2060
2059
2061
2060
// Set up the members collection if it doesn't exist already
2062
2061
if ( ! funcSymbol . members ) {
2063
- funcSymbol . members = createMap < Symbol > ( ) ;
2062
+ funcSymbol . members = new StringMap < Symbol > ( ) ;
2064
2063
}
2065
2064
2066
2065
// Declare the method/property
@@ -2093,7 +2092,7 @@ namespace ts {
2093
2092
bindAnonymousDeclaration ( node , SymbolFlags . Class , bindingName ) ;
2094
2093
// Add name of class expression into the map for semantic classifier
2095
2094
if ( node . name ) {
2096
- classifiableNames [ node . name . text ] = node . name . text ;
2095
+ classifiableNames . add ( node . name . text ) ;
2097
2096
}
2098
2097
}
2099
2098
@@ -2109,14 +2108,15 @@ namespace ts {
2109
2108
// module might have an exported variable called 'prototype'. We can't allow that as
2110
2109
// that would clash with the built-in 'prototype' for the class.
2111
2110
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 ) {
2113
2113
if ( node . name ) {
2114
2114
node . name . parent = node ;
2115
2115
}
2116
- file . bindDiagnostics . push ( createDiagnosticForNode ( symbol . exports [ prototypeSymbol . name ] . declarations [ 0 ] ,
2116
+ file . bindDiagnostics . push ( createDiagnosticForNode ( symbolExport . declarations [ 0 ] ,
2117
2117
Diagnostics . Duplicate_identifier_0 , prototypeSymbol . name ) ) ;
2118
2118
}
2119
- symbol . exports [ prototypeSymbol . name ] = prototypeSymbol ;
2119
+ symbol . exports . set ( prototypeSymbol . name , prototypeSymbol ) ;
2120
2120
prototypeSymbol . parent = symbol ;
2121
2121
}
2122
2122
0 commit comments