Skip to content

Commit 2672042

Browse files
MaxGraeydcodeIO
authored andcommitted
Speedup loader's __getArray (AssemblyScript#814)
1 parent bc48898 commit 2672042

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/loader/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,11 @@ function postInstantiate(baseModule, instance) {
199199

200200
/** Reads (copies) the values of an array from the module's memory. */
201201
function __getArray(arr) {
202-
return Array.from(__getArrayView(arr));
202+
const input = __getArrayView(arr);
203+
const len = input.length;
204+
const out = new Array(len);
205+
for (let i = 0; i < len; i++) out[i] = input[i];
206+
return out;
203207
}
204208

205209
baseModule.__getArray = __getArray;

0 commit comments

Comments
 (0)