Reduce syscall/js calls needed to load Uint8Array

Reimplements the uint8ArrayValueToBytes js util used for copying buffers
from js into wasm using TypedArray.prototype.set to improve performance.
This commit is contained in:
Slugalisk
2019-07-15 05:18:39 -07:00
committed by Sean DuBois
parent 41d39a16af
commit 632530bc69
2 changed files with 3 additions and 3 deletions

View File

@@ -162,8 +162,7 @@ func recoveryToError(e interface{}) error {
func uint8ArrayValueToBytes(val js.Value) []byte {
result := make([]byte, val.Length())
for i := 0; i < val.Length(); i++ {
result[i] = byte(val.Index(i).Int())
}
jsResult := js.TypedArrayOf(result)
jsResult.Call("set", val)
return result
}