Skip to content

Commit

Permalink
Use TypedArray.set to copy a bunch of bytes (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Dec 5, 2021
1 parent c2df543 commit e2c14a1
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions Runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit e2c14a1

Please sign in to comment.