@@ -112,8 +112,8 @@ export interface ExportInfoMap {
112
112
isUsableByFile ( importingFile : Path ) : boolean ;
113
113
clear ( ) : void ;
114
114
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 ;
117
117
releaseSymbols ( ) : void ;
118
118
isEmpty ( ) : boolean ;
119
119
/** @returns Whether the change resulted in the cache being cleared */
@@ -127,10 +127,11 @@ export interface CacheableExportInfoMapHost {
127
127
getGlobalTypingsCacheLocation ( ) : string | undefined ;
128
128
}
129
129
130
+ export type ExportMapInfoKey = string & { __exportInfoKey : void ; } ;
130
131
/** @internal */
131
132
export function createCacheableExportInfoMap ( host : CacheableExportInfoMapHost ) : ExportInfoMap {
132
133
let exportInfoId = 1 ;
133
- const exportInfo = createMultiMap < string , CachedSymbolExportInfo > ( ) ;
134
+ const exportInfo = createMultiMap < ExportMapInfoKey , CachedSymbolExportInfo > ( ) ;
134
135
const symbols = new Map < number , [ symbol : Symbol , moduleSymbol : Symbol ] > ( ) ;
135
136
/**
136
137
* Key: node_modules package name (no @types).
@@ -266,7 +267,7 @@ export function createCacheableExportInfoMap(host: CacheableExportInfoMapHost):
266
267
} ,
267
268
} ;
268
269
if ( Debug . isDebugging ) {
269
- Object . defineProperty ( cache , "__cache" , { get : ( ) => exportInfo } ) ;
270
+ Object . defineProperty ( cache , "__cache" , { value : exportInfo } ) ;
270
271
}
271
272
return cache ;
272
273
@@ -309,14 +310,19 @@ export function createCacheableExportInfoMap(host: CacheableExportInfoMapHost):
309
310
} ;
310
311
}
311
312
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 ) {
313
314
const moduleKey = ambientModuleName || "" ;
314
- return `${ importedName } | ${ getSymbolId ( skipAlias ( symbol , checker ) ) } | ${ moduleKey } ` ;
315
+ return `${ importedName . length } ${ getSymbolId ( skipAlias ( symbol , checker ) ) } ${ importedName } ${ moduleKey } ` as ExportMapInfoKey ;
315
316
}
316
317
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 ) ;
320
326
const ambientModuleName = moduleKey === "" ? undefined : moduleKey ;
321
327
return { symbolName, ambientModuleName } ;
322
328
}
0 commit comments