aboutsummaryrefslogtreecommitdiff
path: root/src/compress
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-09-30 12:31:18 -0400
committerRuss Cox <rsc@golang.org>2014-09-30 12:31:18 -0400
commita6abe22eb6f85f1df9d0f34da82b45ef11759815 (patch)
tree363ddbdb15c347da4b13c5b692ff2da15770ac6e /src/compress
parent02395953064127f7dd54b238442eb71a2077ddb8 (diff)
downloadgo-a6abe22eb6f85f1df9d0f34da82b45ef11759815.tar.xz
compress/*: note that NewReader may introduce buffering
Fixes #8309. LGTM=r R=golang-codereviews, r CC=golang-codereviews, iant https://golang.org/cl/147380043
Diffstat (limited to 'src/compress')
-rw-r--r--src/compress/bzip2/bzip2.go2
-rw-r--r--src/compress/flate/inflate.go8
-rw-r--r--src/compress/gzip/gunzip.go3
-rw-r--r--src/compress/lzw/reader.go2
4 files changed, 11 insertions, 4 deletions
diff --git a/src/compress/bzip2/bzip2.go b/src/compress/bzip2/bzip2.go
index d318116a18..15575d2202 100644
--- a/src/compress/bzip2/bzip2.go
+++ b/src/compress/bzip2/bzip2.go
@@ -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)
diff --git a/src/compress/flate/inflate.go b/src/compress/flate/inflate.go
index 769ef42997..a7fe94c50c 100644
--- a/src/compress/flate/inflate.go
+++ b/src/compress/flate/inflate.go
@@ -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)
diff --git a/src/compress/gzip/gunzip.go b/src/compress/gzip/gunzip.go
index 4f398b194a..fc08c7a48c 100644
--- a/src/compress/gzip/gunzip.go
+++ b/src/compress/gzip/gunzip.go
@@ -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)
diff --git a/src/compress/lzw/reader.go b/src/compress/lzw/reader.go
index cd90c9c63a..0835bd8b90 100644
--- a/src/compress/lzw/reader.go
+++ b/src/compress/lzw/reader.go
@@ -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