]> Cypherpunks repositories - gostls13.git/commit
bytes, string: add Reset method to Reader
authorJoe Tsai <joetsai@digital-static.net>
Thu, 31 Mar 2016 23:05:23 +0000 (16:05 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 7 Apr 2016 18:58:01 +0000 (18:58 +0000)
commite88f89028a55acf9c8b76b7f6ca284c3f9eb4cbd
treef33797b9e2ff352667f489fa04e04fad7f2b0d05
parente6f36f0cd5b45b9ce7809a34c45aeb66a5ca64a4
bytes, string: add Reset method to Reader

Currently, there is no easy allocation-free way to turn a
[]byte or string into an io.Reader. Thus, we add a Reset method
to bytes.Reader and strings.Reader to allow the reuse of these
Readers with another []byte or string.

This is consistent with the fact that many standard library io.Readers
already support a Reset method of some type:
bufio.Reader
flate.Reader
gzip.Reader
zlib.Reader
debug/dwarf.LineReader
bytes.Buffer
crypto/rc4.Cipher

Fixes #15033

Change-Id: I456fd1af77af6ef0b4ac6228b058ac1458ff3d19
Reviewed-on: https://go-review.googlesource.com/21386
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/bytes/reader.go
src/bytes/reader_test.go
src/strings/reader.go
src/strings/reader_test.go