]> Cypherpunks repositories - gostls13.git/commit
io: Prioritize WriterTos over ReaderFroms in Copy.
authorDaniel Morsing <daniel.morsing@gmail.com>
Thu, 23 May 2013 16:29:19 +0000 (18:29 +0200)
committerDaniel Morsing <daniel.morsing@gmail.com>
Thu, 23 May 2013 16:29:19 +0000 (18:29 +0200)
commitfdc4ce6ec790b1a0507c3c2ef20e94aca4876a1b
tree9d6ffdb2a8a953e0c870d6d2efaab79d25d83e10
parent876455f3ba0e3ee66e177cf901ff5ea9c5aa9f07
io: Prioritize WriterTos over ReaderFroms in Copy.

This only affects calls where both ReaderFrom and WriterTo are implemented. WriterTo can issue one large write, while ReaderFrom must Read until EOF, potentially reallocating when out of memory. With one large Write, the Writer only needs to allocate once.

This also helps in ioutil.Discard since we can avoid copying memory when the Reader implements WriterTo.

R=golang-dev, dsymonds, remyoudompheng, bradfitz
CC=golang-dev, minux.ma
https://golang.org/cl/9462044
src/pkg/io/io.go
src/pkg/io/io_test.go