Skip to content

Commit e2c14a1

Browse files
Use TypedArray.set to copy a bunch of bytes (#146)
1 parent c2df543 commit e2c14a1

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

Runtime/src/index.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,7 @@ export class SwiftRuntime {
222222

223223
const writeString = (ptr: pointer, bytes: Uint8Array) => {
224224
const uint8Memory = new Uint8Array(memory().buffer);
225-
for (const [index, byte] of bytes.entries()) {
226-
uint8Memory[ptr + index] = byte;
227-
}
228-
uint8Memory[ptr];
225+
uint8Memory.set(bytes, ptr);
229226
};
230227

231228
const readUInt32 = (ptr: pointer) => {

0 commit comments

Comments
 (0)