Skip to content

Commit 9c42104

Browse files
Try to reuse buffers across sourcemap generation.
1 parent 070005f commit 9c42104

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/compiler/sourcemap.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace ts {
66

77
declare let TextDecoder: undefined | (new() => { decode(buffer: ArrayBuffer | ArrayBufferView): string });
88
const decoder = new (typeof TextDecoder !== "undefined" ? TextDecoder : require("util").TextDecoder)();
9+
let mappingsBuffer: Uint8Array;
910

1011
export function createSourceMapGenerator(host: EmitHost, file: string, guessedInputLength: number, sourceRoot: string, sourcesDirectoryPath: string, generatorOptions: SourceMapGeneratorOptions): SourceMapGenerator {
1112
const { enter, exit } = generatorOptions.extendedDiagnostics
@@ -20,7 +21,7 @@ namespace ts {
2021

2122
const names: string[] = [];
2223
let nameToNameIndexMap: ESMap<string, number> | undefined;
23-
let mappingsBuffer = new Uint8Array(guessedInputLength + 1 >> 1);
24+
mappingsBuffer ||= new Uint8Array(guessedInputLength + 1 >> 1);
2425
let lastMappings: string | undefined;
2526
let mappingsPos = 0;
2627
function setMapping(charCode: number) {

0 commit comments

Comments
 (0)