1- /// <reference path="core.ts"/>
1+ /// <reference path="core.ts"/>
22/// <reference path="utilities.ts"/>
33
44/* @internal */
@@ -2641,9 +2641,11 @@ namespace ts {
26412641 return destEmitNode ;
26422642 }
26432643
2644- function mergeTokenSourceMapRanges ( sourceRanges : Map < TextRange > , destRanges : Map < TextRange > ) {
2645- if ( ! destRanges ) destRanges = createMap < TextRange > ( ) ;
2646- copyMapEntries ( sourceRanges , destRanges ) ;
2644+ function mergeTokenSourceMapRanges ( sourceRanges : SparseArray < TextRange > , destRanges : SparseArray < TextRange > ) {
2645+ if ( ! destRanges ) destRanges = [ ] ;
2646+ for ( const key in sourceRanges ) {
2647+ destRanges [ key ] = sourceRanges [ key ] ;
2648+ }
26472649 return destRanges ;
26482650 }
26492651
@@ -2745,7 +2747,7 @@ namespace ts {
27452747 export function getTokenSourceMapRange ( node : Node , token : SyntaxKind ) {
27462748 const emitNode = node . emitNode ;
27472749 const tokenSourceMapRanges = emitNode && emitNode . tokenSourceMapRanges ;
2748- return tokenSourceMapRanges && tokenSourceMapRanges . get ( token ) ;
2750+ return tokenSourceMapRanges && tokenSourceMapRanges [ token ] ;
27492751 }
27502752
27512753 /**
@@ -2757,8 +2759,8 @@ namespace ts {
27572759 */
27582760 export function setTokenSourceMapRange < T extends Node > ( node : T , token : SyntaxKind , range : TextRange ) {
27592761 const emitNode = getOrCreateEmitNode ( node ) ;
2760- const tokenSourceMapRanges = emitNode . tokenSourceMapRanges || ( emitNode . tokenSourceMapRanges = createMap < TextRange > ( ) ) ;
2761- tokenSourceMapRanges . set ( token , range ) ;
2762+ const tokenSourceMapRanges = emitNode . tokenSourceMapRanges || ( emitNode . tokenSourceMapRanges = [ ] ) ;
2763+ tokenSourceMapRanges [ token ] = range ;
27622764 return node ;
27632765 }
27642766
@@ -3270,7 +3272,7 @@ namespace ts {
32703272 externalImports : ( ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration ) [ ] ; // imports of other external modules
32713273 externalHelpersImportDeclaration : ImportDeclaration | undefined ; // import of external helpers
32723274 exportSpecifiers : Map < ExportSpecifier [ ] > ; // export specifiers by name
3273- exportedBindings : Map < Identifier [ ] > ; // exported names of local declarations
3275+ exportedBindings : SparseArray < Identifier [ ] > ; // exported names of local declarations
32743276 exportedNames : Identifier [ ] ; // all exported names local to module
32753277 exportEquals : ExportAssignment | undefined ; // an export= declaration if one was present
32763278 hasExportStarsToExportValues : boolean ; // whether this module contains export*
@@ -3279,7 +3281,7 @@ namespace ts {
32793281 export function collectExternalModuleInfo ( sourceFile : SourceFile , resolver : EmitResolver , compilerOptions : CompilerOptions ) : ExternalModuleInfo {
32803282 const externalImports : ( ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration ) [ ] = [ ] ;
32813283 const exportSpecifiers = createMap < ExportSpecifier [ ] > ( ) ;
3282- const exportedBindings = createMap < Identifier [ ] > ( ) ;
3284+ const exportedBindings = sparseArray < Identifier [ ] > ( ) ;
32833285 const uniqueExports = createMap < boolean > ( ) ;
32843286 let exportedNames : Identifier [ ] ;
32853287 let hasExportDefault = false ;
@@ -3338,7 +3340,7 @@ namespace ts {
33383340 || resolver . getReferencedValueDeclaration ( name ) ;
33393341
33403342 if ( decl ) {
3341- multiMapAdd ( exportedBindings , getOriginalNodeId ( decl ) , specifier . name ) ;
3343+ multiMapSparseArrayAdd ( exportedBindings , getOriginalNodeId ( decl ) , specifier . name ) ;
33423344 }
33433345
33443346 uniqueExports . set ( specifier . name . text , true ) ;
@@ -3368,15 +3370,15 @@ namespace ts {
33683370 if ( hasModifier ( node , ModifierFlags . Default ) ) {
33693371 // export default function() { }
33703372 if ( ! hasExportDefault ) {
3371- multiMapAdd ( exportedBindings , getOriginalNodeId ( node ) , getDeclarationName ( < FunctionDeclaration > node ) ) ;
3373+ multiMapSparseArrayAdd ( exportedBindings , getOriginalNodeId ( node ) , getDeclarationName ( < FunctionDeclaration > node ) ) ;
33723374 hasExportDefault = true ;
33733375 }
33743376 }
33753377 else {
33763378 // export function x() { }
33773379 const name = ( < FunctionDeclaration > node ) . name ;
33783380 if ( ! uniqueExports . get ( name . text ) ) {
3379- multiMapAdd ( exportedBindings , getOriginalNodeId ( node ) , name ) ;
3381+ multiMapSparseArrayAdd ( exportedBindings , getOriginalNodeId ( node ) , name ) ;
33803382 uniqueExports . set ( name . text , true ) ;
33813383 exportedNames = append ( exportedNames , name ) ;
33823384 }
@@ -3389,15 +3391,15 @@ namespace ts {
33893391 if ( hasModifier ( node , ModifierFlags . Default ) ) {
33903392 // export default class { }
33913393 if ( ! hasExportDefault ) {
3392- multiMapAdd ( exportedBindings , getOriginalNodeId ( node ) , getDeclarationName ( < ClassDeclaration > node ) ) ;
3394+ multiMapSparseArrayAdd ( exportedBindings , getOriginalNodeId ( node ) , getDeclarationName ( < ClassDeclaration > node ) ) ;
33933395 hasExportDefault = true ;
33943396 }
33953397 }
33963398 else {
33973399 // export class x { }
33983400 const name = ( < ClassDeclaration > node ) . name ;
33993401 if ( ! uniqueExports . get ( name . text ) ) {
3400- multiMapAdd ( exportedBindings , getOriginalNodeId ( node ) , name ) ;
3402+ multiMapSparseArrayAdd ( exportedBindings , getOriginalNodeId ( node ) , name ) ;
34013403 uniqueExports . set ( name . text , true ) ;
34023404 exportedNames = append ( exportedNames , name ) ;
34033405 }
0 commit comments