Optimize block concatenation by replacing concat with iterative push to prevent large allocations.

This commit is contained in:
SKProCH committed 2025-10-09 21:12:27 +03:00
1 parent 17552e2fda
commit 35e158fce8
1 file changed
+7 -3
+7 -3
View File
@@ -8437,9 +8437,11 @@ function getText(key, params) {
}
}
// Concatenate all blocks (avoid spread on large arrays)
// Append all blocks without spread/concat to avoid large allocations and argument explosion
for (const block of blocks) {
coords = coords.concat(block);
for (let i = 0; i < block.length; i++) {
coords.push(block[i]);
}
}
} else {
throw new Error(`Unknown mode: ${mode}`);
@@ -10737,7 +10739,9 @@ async function generateCoordinatesAsync(
}
}
for (const block of blocks) {
coords = coords.concat(block); // avoid spread on huge arrays
for (let i = 0; i < block.length; i++) {
coords.push(block[i]);
}
}
} else {
throw new Error('Unknown mode: ' + mode);