mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2026-02-06 11:17:36 +00:00
Optimize data concatenation in EJS_Download by using Blob to reduce iterations
This commit is contained in:
parent
3d824853af
commit
8cf9114b9d
@ -133,12 +133,10 @@ class EJS_Download {
|
||||
onProgress("downloading", Math.floor(received / contentLength * 100), received, contentLength);
|
||||
}
|
||||
}
|
||||
data = new Uint8Array(chunks.reduce((acc, val) => acc + val.length, 0));
|
||||
let offset = 0;
|
||||
for (const chunk of chunks) {
|
||||
data.set(chunk, offset);
|
||||
offset += chunk.length;
|
||||
}
|
||||
// Optimize concatenation by leveraging Blob to avoid double iteration
|
||||
const blob = new Blob(chunks);
|
||||
const ab = await blob.arrayBuffer();
|
||||
data = new Uint8Array(ab);
|
||||
} else {
|
||||
data = await resp[responseType]();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user