@@ -112,8 +112,8 @@ export interface ExportInfoMap {
112112 isUsableByFile ( importingFile : Path ) : boolean ;
113113 clear ( ) : void ;
114114 add ( importingFile : Path , symbol : Symbol , key : __String , moduleSymbol : Symbol , moduleFile : SourceFile | undefined , exportKind : ExportKind , isFromPackageJson : boolean , checker : TypeChecker ) : void ;
115- get ( importingFile : Path , key : string ) : readonly SymbolExportInfo [ ] | undefined ;
116- 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 ;
115+ get ( importingFile : Path , key : ExportMapInfoKey ) : readonly SymbolExportInfo [ ] | undefined ;
116+ 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 ;
117117 releaseSymbols ( ) : void ;
118118 isEmpty ( ) : boolean ;
119119 /** @returns Whether the change resulted in the cache being cleared */
@@ -127,10 +127,11 @@ export interface CacheableExportInfoMapHost {
127127 getGlobalTypingsCacheLocation ( ) : string | undefined ;
128128}
129129
130+ export type ExportMapInfoKey = string & { __exportInfoKey : void ; } ;
130131/** @internal */
131132export function createCacheableExportInfoMap ( host : CacheableExportInfoMapHost ) : ExportInfoMap {
132133 let exportInfoId = 1 ;
133- const exportInfo = createMultiMap < string , CachedSymbolExportInfo > ( ) ;
134+ const exportInfo = createMultiMap < ExportMapInfoKey , CachedSymbolExportInfo > ( ) ;
134135 const symbols = new Map < number , [ symbol : Symbol , moduleSymbol : Symbol ] > ( ) ;
135136 /**
136137 * Key: node_modules package name (no @types).
@@ -266,7 +267,7 @@ export function createCacheableExportInfoMap(host: CacheableExportInfoMapHost):
266267 } ,
267268 } ;
268269 if ( Debug . isDebugging ) {
269- Object . defineProperty ( cache , "__cache" , { get : ( ) => exportInfo } ) ;
270+ Object . defineProperty ( cache , "__cache" , { value : exportInfo } ) ;
270271 }
271272 return cache ;
272273
@@ -309,14 +310,19 @@ export function createCacheableExportInfoMap(host: CacheableExportInfoMapHost):
309310 } ;
310311 }
311312
312- function key ( importedName : string , symbol : Symbol , ambientModuleName : string | undefined , checker : TypeChecker ) : string {
313+ function key ( importedName : string , symbol : Symbol , ambientModuleName : string | undefined , checker : TypeChecker ) {
313314 const moduleKey = ambientModuleName || "" ;
314- return `${ importedName } | ${ getSymbolId ( skipAlias ( symbol , checker ) ) } | ${ moduleKey } ` ;
315+ return `${ importedName . length } ${ getSymbolId ( skipAlias ( symbol , checker ) ) } ${ importedName } ${ moduleKey } ` as ExportMapInfoKey ;
315316 }
316317
317- function parseKey ( key : string ) {
318- const symbolName = key . substring ( 0 , key . indexOf ( "|" ) ) ;
319- const moduleKey = key . substring ( key . lastIndexOf ( "|" ) + 1 ) ;
318+ function parseKey ( key : ExportMapInfoKey ) {
319+ const firstSpace = key . indexOf ( " " ) ;
320+ const secondSpace = key . indexOf ( " " , firstSpace + 1 ) ;
321+ const symbolNameLength = parseInt ( key . substring ( 0 , firstSpace ) , 10 ) ;
322+
323+ const data = key . substring ( secondSpace + 1 ) ;
324+ const symbolName = data . substring ( 0 , symbolNameLength ) ;
325+ const moduleKey = data . substring ( symbolNameLength + 1 ) ;
320326 const ambientModuleName = moduleKey === "" ? undefined : moduleKey ;
321327 return { symbolName, ambientModuleName } ;
322328 }
0 commit comments