Skip to content

Commit 1e84ffc

Browse files
authored
Optimize source mapping into external source map sources (microsoft#40055)
1 parent 6a622a1 commit 1e84ffc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/compiler/sourcemap.ts

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace ts {
1313
const rawSources: string[] = [];
1414
const sources: string[] = [];
1515
const sourceToSourceIndexMap = new Map<string, number>();
16+
const fileNameToSourceIndexMap = new Map<string, number>();
1617
let sourcesContent: (string | null)[] | undefined;
1718

1819
const names: string[] = [];
@@ -51,6 +52,10 @@ namespace ts {
5152

5253
function addSource(fileName: string) {
5354
enter();
55+
const sourceIndexByFileName = fileNameToSourceIndexMap.get(fileName);
56+
if (sourceIndexByFileName !== undefined) {
57+
return sourceIndexByFileName;
58+
}
5459
const source = getRelativePathToDirectoryOrUrl(sourcesDirectoryPath,
5560
fileName,
5661
host.getCurrentDirectory(),
@@ -64,6 +69,7 @@ namespace ts {
6469
rawSources.push(fileName);
6570
sourceToSourceIndexMap.set(source, sourceIndex);
6671
}
72+
fileNameToSourceIndexMap.set(fileName, sourceIndex);
6773
exit();
6874
return sourceIndex;
6975
}

0 commit comments

Comments
 (0)