From 1e571b4a5c96ca251e47f46d6aa823cbb6f32560 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sat, 4 Dec 2021 06:31:11 +0000 Subject: [PATCH] Use TypedArray.set to copy a bunch of bytes --- Runtime/src/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Runtime/src/index.ts b/Runtime/src/index.ts index 6fc139443..f0639b09c 100644 --- a/Runtime/src/index.ts +++ b/Runtime/src/index.ts @@ -222,10 +222,7 @@ export class SwiftRuntime { const writeString = (ptr: pointer, bytes: Uint8Array) => { const uint8Memory = new Uint8Array(memory().buffer); - for (const [index, byte] of bytes.entries()) { - uint8Memory[ptr + index] = byte; - } - uint8Memory[ptr]; + uint8Memory.set(bytes, ptr); }; const readUInt32 = (ptr: pointer) => {