mirror of
https://github.com/pion/webrtc.git
synced 2025-11-02 03:32:48 +08:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user