mirror of
https://github.com/pion/webrtc.git
synced 2025-11-03 09:40:59 +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:
@@ -123,6 +123,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
|
||||
* [mchlrhw](https://github.com/mchlrhw)
|
||||
* [AlexWoo(武杰)](https://github.com/AlexWoo) *Fix RemoteDescription parsing for certificate fingerprint*
|
||||
* [Cecylia Bocovich](https://github.com/cohosh)
|
||||
* [Slugalisk](https://github.com/slugalisk)
|
||||
|
||||
### License
|
||||
MIT License - see [LICENSE](LICENSE) for full text
|
||||
|
||||
@@ -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