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

@@ -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

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
}