hashicorp / yamux

Golang connection multiplexing library
Mozilla Public License 2.0
2.19k stars 232 forks source link

Remove unnecessary *bytes.Reader in Stream.Write() #97

Closed jacobvosmaer closed 2 years ago

jacobvosmaer commented 2 years ago

Prior to this change, each call to Stream.Write() would allocate 1 or more *bytes.Reader instances. While these are small, it makes the Go garbage collector do unnecessary work.

Besides the inefficiency at the machine level, it also makes no sense at the human level to create an io.Reader and use io.Copy when a single Write() call suffices.