mirror of
https://github.com/tiennm99/WPlace-AutoBOT.git
synced 2026-10-11 03:13:01 +00:00
Optimize block concatenation by replacing concat with iterative push to prevent large allocations.
This commit is contained in:
1 parent
17552e2fda
commit
35e158fce8
1 file changed
+7
-3
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user