@@ -113,8 +113,8 @@ export interface ExportInfoMap {
113113 isUsableByFile ( importingFile : Path ) : boolean ;
114114 clear ( ) : void ;
115115 add ( importingFile : Path , symbol : Symbol , key : __String , moduleSymbol : Symbol , moduleFile : SourceFile | undefined , exportKind : ExportKind , isFromPackageJson : boolean , checker : TypeChecker ) : void ;
116- get ( importingFile : Path , key : string ) : readonly SymbolExportInfo [ ] | undefined ;
117- search < T > ( importingFile : Path , preferCapitalized : boolean , matches : ( name : string , targetFlags : SymbolFlags ) => boolean , action : ( info : readonly SymbolExportInfo [ ] , symbolName : string , isFromAmbientModule : boolean , key : string ) => T | undefined ) : T | undefined ;
116+ get ( importingFile : Path , key : ExportMapInfoKey ) : readonly SymbolExportInfo [ ] | undefined ;
117+ search < T > ( importingFile : Path , preferCapitalized : boolean , matches : ( name : string , targetFlags : SymbolFlags ) => boolean , action : ( info : readonly SymbolExportInfo [ ] , symbolName : string , isFromAmbientModule : boolean , key : ExportMapInfoKey ) => T | undefined ) : T | undefined ;
118118 releaseSymbols ( ) : void ;
119119 isEmpty ( ) : boolean ;
120120 /** @returns Whether the change resulted in the cache being cleared */
@@ -128,10 +128,11 @@ export interface CacheableExportInfoMapHost {
128128 getGlobalTypingsCacheLocation ( ) : string | undefined ;
129129}
130130
131+ export type ExportMapInfoKey = string & { __exportInfoKey : void ; } ;
131132/** @internal */
132133export function createCacheableExportInfoMap ( host : CacheableExportInfoMapHost ) : ExportInfoMap {
133134 let exportInfoId = 1 ;
134- const exportInfo = createMultiMap < string , CachedSymbolExportInfo > ( ) ;
135+ const exportInfo = createMultiMap < ExportMapInfoKey , CachedSymbolExportInfo > ( ) ;
135136 const symbols = new Map < number , [ symbol : Symbol , moduleSymbol : Symbol ] > ( ) ;
136137 /**
137138 * Key: node_modules package name (no @types).
@@ -267,7 +268,7 @@ export function createCacheableExportInfoMap(host: CacheableExportInfoMapHost):
267268 } ,
268269 } ;
269270 if ( Debug . isDebugging ) {
270- Object . defineProperty ( cache , "__cache" , { get : ( ) => exportInfo } ) ;
271+ Object . defineProperty ( cache , "__cache" , { value : exportInfo } ) ;
271272 }
272273 return cache ;
273274
@@ -310,14 +311,19 @@ export function createCacheableExportInfoMap(host: CacheableExportInfoMapHost):
310311 } ;
311312 }
312313
313- function key ( importedName : string , symbol : Symbol , ambientModuleName : string | undefined , checker : TypeChecker ) : string {
314+ function key ( importedName : string , symbol : Symbol , ambientModuleName : string | undefined , checker : TypeChecker ) {
314315 const moduleKey = ambientModuleName || "" ;
315- return `${ importedName } | ${ getSymbolId ( skipAlias ( symbol , checker ) ) } | ${ moduleKey } ` ;
316+ return `${ importedName . length } ${ getSymbolId ( skipAlias ( symbol , checker ) ) } ${ importedName } ${ moduleKey } ` as ExportMapInfoKey ;
316317 }
317318
318- function parseKey ( key : string ) {
319- const symbolName = key . substring ( 0 , key . indexOf ( "|" ) ) ;
320- const moduleKey = key . substring ( key . lastIndexOf ( "|" ) + 1 ) ;
319+ function parseKey ( key : ExportMapInfoKey ) {
320+ const firstSpace = key . indexOf ( " " ) ;
321+ const secondSpace = key . indexOf ( " " , firstSpace + 1 ) ;
322+ const symbolNameLength = parseInt ( key . substring ( 0 , firstSpace ) , 10 ) ;
323+
324+ const data = key . substring ( secondSpace + 1 ) ;
325+ const symbolName = data . substring ( 0 , symbolNameLength ) ;
326+ const moduleKey = data . substring ( symbolNameLength + 1 ) ;
321327 const ambientModuleName = moduleKey === "" ? undefined : moduleKey ;
322328 return { symbolName, ambientModuleName } ;
323329 }
0 commit comments