Skip to content

Commit

Permalink
use String.fromCharCode.apply() in WASM ver.
Browse files Browse the repository at this point in the history
  • Loading branch information
gfx committed May 15, 2019
1 parent eea2f04 commit dfe06c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions benchmark/string.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { encode, decode } from "../src";

const data = "Hello, 🌏\n".repeat(1000);
const data = "Hello, 🌏\n".repeat(10000);

// warm up
const encoded = encode(data);
Expand All @@ -9,13 +9,13 @@ decode(encoded);
// run

console.time("encode");
for (let i = 0; i < 10000; i++) {
for (let i = 0; i < 1000; i++) {
encode(data);
}
console.timeEnd("encode");

console.time("decode");
for (let i = 0; i < 10000; i++) {
for (let i = 0; i < 1000; i++) {
decode(encoded);
}
console.timeEnd("decode");
2 changes: 1 addition & 1 deletion wasmModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ export function utf8Decode2(bytes: Uint8Array, offset: number, byteLength: numbe
// console.log([byteLength, outputStart, outputEnd]);
// console.log(instanceMemory.subarray(0, 10));
// console.log(utf16array);
return String.fromCharCode(...utf16array);
return String.fromCharCode.apply(String, utf16array as any);
}

0 comments on commit dfe06c3

Please sign in to comment.