Skip to content

Commit 4c86404

Browse files
Use an array for building up mappings in the sourcemap generator.
1 parent c552a4b commit 4c86404

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/compiler/sourcemap.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace ts {
1717

1818
const names: string[] = [];
1919
let nameToNameIndexMap: ESMap<string, number> | undefined;
20-
let mappings = "";
20+
let mappings: string[] = [];
2121

2222
// Last recorded and encoded mappings
2323
let lastGeneratedLine = 0;
@@ -221,7 +221,7 @@ namespace ts {
221221
if (lastGeneratedLine < pendingGeneratedLine) {
222222
// Emit line delimiters
223223
do {
224-
mappings += ";";
224+
mappings.push(";");
225225
lastGeneratedLine++;
226226
lastGeneratedCharacter = 0;
227227
}
@@ -231,30 +231,30 @@ namespace ts {
231231
Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack");
232232
// Emit comma to separate the entry
233233
if (hasLast) {
234-
mappings += ",";
234+
mappings.push(",");
235235
}
236236
}
237237

238238
// 1. Relative generated character
239-
mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter);
239+
mappings.push(base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter));
240240
lastGeneratedCharacter = pendingGeneratedCharacter;
241241

242242
if (hasPendingSource) {
243243
// 2. Relative sourceIndex
244-
mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex);
244+
mappings.push(base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex));
245245
lastSourceIndex = pendingSourceIndex;
246246

247247
// 3. Relative source line
248-
mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine);
248+
mappings.push(base64VLQFormatEncode(pendingSourceLine - lastSourceLine));
249249
lastSourceLine = pendingSourceLine;
250250

251251
// 4. Relative source character
252-
mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter);
252+
mappings.push(base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter));
253253
lastSourceCharacter = pendingSourceCharacter;
254254

255255
if (hasPendingName) {
256256
// 5. Relative nameIndex
257-
mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex);
257+
mappings.push(base64VLQFormatEncode(pendingNameIndex - lastNameIndex));
258258
lastNameIndex = pendingNameIndex;
259259
}
260260
}
@@ -271,7 +271,7 @@ namespace ts {
271271
sourceRoot,
272272
sources,
273273
names,
274-
mappings,
274+
mappings: mappings.join(),
275275
sourcesContent,
276276
};
277277
}

0 commit comments

Comments
 (0)