Skip to content

Commit

Permalink
Reduce syscall/js calls needed to load Uint8Array
Browse files Browse the repository at this point in the history
Reimplements the uint8ArrayValueToBytes js util used for copying buffers
from js into wasm using TypedArray.prototype.set to improve performance.
  • Loading branch information
slugalisk authored and Sean-Der committed Jul 15, 2019
1 parent 41d39a1 commit 632530b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -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
5 changes: 2 additions & 3 deletions js_utils.go
Expand Up @@ -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
}

0 comments on commit 632530b

Please sign in to comment.