mirror of
https://github.com/golang/go.git
synced 2025-05-25 09:21:21 +00:00
compress/*: note that NewReader may introduce buffering
Fixes #8309. LGTM=r R=golang-codereviews, r CC=golang-codereviews, iant https://golang.org/cl/147380043
This commit is contained in:
parent
0239595306
commit
a6abe22eb6
@ -42,6 +42,8 @@ type reader struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewReader returns an io.Reader which decompresses bzip2 data from r.
|
// 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 {
|
func NewReader(r io.Reader) io.Reader {
|
||||||
bz2 := new(reader)
|
bz2 := new(reader)
|
||||||
bz2.br = newBitReader(r)
|
bz2.br = newBitReader(r)
|
||||||
|
@ -680,9 +680,11 @@ func makeReader(r io.Reader) Reader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewReader returns a new ReadCloser that can be used
|
// NewReader returns a new ReadCloser that can be used
|
||||||
// to read the uncompressed version of r. It is the caller's
|
// to read the uncompressed version of r.
|
||||||
// responsibility to call Close on the ReadCloser when
|
// If r does not also implement io.ByteReader,
|
||||||
// finished reading.
|
// 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 {
|
func NewReader(r io.Reader) io.ReadCloser {
|
||||||
var f decompressor
|
var f decompressor
|
||||||
f.bits = new([maxLit + maxDist]int)
|
f.bits = new([maxLit + maxDist]int)
|
||||||
|
@ -77,7 +77,8 @@ type Reader struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewReader creates a new Reader reading the given reader.
|
// 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.
|
// It is the caller's responsibility to call Close on the Reader when done.
|
||||||
func NewReader(r io.Reader) (*Reader, error) {
|
func NewReader(r io.Reader) (*Reader, error) {
|
||||||
z := new(Reader)
|
z := new(Reader)
|
||||||
|
@ -222,6 +222,8 @@ func (d *decoder) Close() error {
|
|||||||
|
|
||||||
// NewReader creates a new io.ReadCloser.
|
// NewReader creates a new io.ReadCloser.
|
||||||
// Reads from the returned io.ReadCloser read and decompress data from r.
|
// 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
|
// It is the caller's responsibility to call Close on the ReadCloser when
|
||||||
// finished reading.
|
// finished reading.
|
||||||
// The number of bits to use for literal codes, litWidth, must be in the
|
// The number of bits to use for literal codes, litWidth, must be in the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user