Skip to content

Commit 028f861

Browse files
VivianHublovvnsrzn
authored andcommitted
perf: uint8array set method instead of spread
1 parent e841a53 commit 028f861

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/hub/src/utils/XetBlob.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,11 @@ export class XetBlob extends Blob {
327327
totalFetchBytes += result.value.byteLength;
328328

329329
if (leftoverBytes) {
330-
result.value = new Uint8Array([...leftoverBytes, ...result.value]);
331-
leftoverBytes = undefined;
330+
const leftoverBytesLength: number = leftoverBytes.length;
331+
const combinedBytes = new Uint8Array(leftoverBytesLength + result.value.length);
332+
combinedBytes.set(leftoverBytes);
333+
combinedBytes.set(result.value, leftoverBytesLength);
334+
result.value = combinedBytes;
332335
}
333336

334337
while (totalBytesRead < maxBytes && result.value.byteLength) {

0 commit comments

Comments
 (0)