]> Cypherpunks repositories - gostls13.git/commitdiff
compress/*: note that NewReader may introduce buffering
authorRuss Cox <rsc@golang.org>
Tue, 30 Sep 2014 16:31:18 +0000 (12:31 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 30 Sep 2014 16:31:18 +0000 (12:31 -0400)
Fixes #8309.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, iant
https://golang.org/cl/147380043

src/compress/bzip2/bzip2.go
src/compress/flate/inflate.go
src/compress/gzip/gunzip.go
src/compress/lzw/reader.go

index d318116a1873bf38b438b685e01eb21a338300d8..15575d22023e431aa65e392c6a9d8c5412434982 100644 (file)
@@ -42,6 +42,8 @@ type reader struct {
 }
 
 // NewReader returns an io.Reader which decompresses bzip2 data from r.
+// If r does not also implement io.ByteReader,
+// the decompressor may read more data than necessary from r.
 func NewReader(r io.Reader) io.Reader {
        bz2 := new(reader)
        bz2.br = newBitReader(r)
index 769ef4299790e6437e7d66b47494b162ccd877ea..a7fe94c50c1635966b0eb567a7377d4ac234fd21 100644 (file)
@@ -680,9 +680,11 @@ func makeReader(r io.Reader) Reader {
 }
 
 // NewReader returns a new ReadCloser that can be used
-// to read the uncompressed version of r.  It is the caller's
-// responsibility to call Close on the ReadCloser when
-// finished reading.
+// to read the uncompressed version of r.
+// If r does not also implement io.ByteReader,
+// the decompressor may read more data than necessary from r.
+// It is the caller's responsibility to call Close on the ReadCloser
+// when finished reading.
 func NewReader(r io.Reader) io.ReadCloser {
        var f decompressor
        f.bits = new([maxLit + maxDist]int)
index 4f398b194a06b3fd96146696cf1d10c7849c96cf..fc08c7a48c53e80079180ae59835f5da11a4057f 100644 (file)
@@ -77,7 +77,8 @@ type Reader struct {
 }
 
 // NewReader creates a new Reader reading the given reader.
-// The implementation buffers input and may read more data than necessary from r.
+// If r does not also implement io.ByteReader,
+// the decompressor may read more data than necessary from r.
 // It is the caller's responsibility to call Close on the Reader when done.
 func NewReader(r io.Reader) (*Reader, error) {
        z := new(Reader)
index cd90c9c63a67289b08386e3f0dad4bccaa4ab143..0835bd8b90b36b5205722d8f951efed647109bd7 100644 (file)
@@ -222,6 +222,8 @@ func (d *decoder) Close() error {
 
 // NewReader creates a new io.ReadCloser.
 // Reads from the returned io.ReadCloser read and decompress data from r.
+// If r does not also implement io.ByteReader,
+// the decompressor may read more data than necessary from r.
 // It is the caller's responsibility to call Close on the ReadCloser when
 // finished reading.
 // The number of bits to use for literal codes, litWidth, must be in the