Verified Commit 23c58481 authored by Camil Staps's avatar Camil Staps 🚀

Speed up JS interface: use TextDecoder to get string from WebAssembly memory

parent 74749311
Pipeline #24181 failed with stage
in 1 minute and 4 seconds
......@@ -326,11 +326,15 @@ const ABC={
get_clean_string: function (hp_ptr) {
var size=ABC.memory_array[hp_ptr/4+2];
var string_buffer=new Uint8Array(ABC.memory.buffer, hp_ptr+16);
var string='';
for (var i=0; i<size; i++)
string+=String.fromCharCode(string_buffer[i]);
return string;
var string_buffer=new Uint8Array(ABC.memory.buffer, hp_ptr+16, size);
if (typeof TextDecoder!='undefined') {
return new TextDecoder('x-user-defined').decode(string_buffer);
} else {
var string='';
for (var i=0; i<size; i++)
string+=String.fromCharCode(string_buffer[i]);
return string;
}
},
addresses: {},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment