Optimize source mapping into external source map sources (#40055)

This commit is contained in:
Joost Koehoorn 2020-08-19 03:09:05 +02:00 committed by GitHub
parent 6a622a11c9
commit 1e84ffc703
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@ namespace ts {
const rawSources: string[] = [];
const sources: string[] = [];
const sourceToSourceIndexMap = new Map<string, number>();
const fileNameToSourceIndexMap = new Map<string, number>();
let sourcesContent: (string | null)[] | undefined;
const names: string[] = [];
@ -51,6 +52,10 @@ namespace ts {
function addSource(fileName: string) {
enter();
const sourceIndexByFileName = fileNameToSourceIndexMap.get(fileName);
if (sourceIndexByFileName !== undefined) {
return sourceIndexByFileName;
}
const source = getRelativePathToDirectoryOrUrl(sourcesDirectoryPath,
fileName,
host.getCurrentDirectory(),
@ -64,6 +69,7 @@ namespace ts {
rawSources.push(fileName);
sourceToSourceIndexMap.set(source, sourceIndex);
}
fileNameToSourceIndexMap.set(fileName, sourceIndex);
exit();
return sourceIndex;
}