diff options
Diffstat (limited to 'libgo/go/compress')
-rw-r--r-- | libgo/go/compress/bzip2/bit_reader.go | 13 | ||||
-rw-r--r-- | libgo/go/compress/flate/inflate.go | 8 |
2 files changed, 10 insertions, 11 deletions
diff --git a/libgo/go/compress/bzip2/bit_reader.go b/libgo/go/compress/bzip2/bit_reader.go index b35c69a1cca..ab1d6065143 100644 --- a/libgo/go/compress/bzip2/bit_reader.go +++ b/libgo/go/compress/bzip2/bit_reader.go @@ -14,21 +14,16 @@ import ( // because the error handling was verbose. Instead, any error is kept and can // be checked afterwards. type bitReader struct { - r byteReader + r io.ByteReader n uint64 bits uint err error } -// bitReader needs to read bytes from an io.Reader. We attempt to convert the -// given io.Reader to this interface and, if it doesn't already fit, we wrap in -// a bufio.Reader. -type byteReader interface { - ReadByte() (byte, error) -} - +// newBitReader returns a new bitReader reading from r. If r is not +// already an io.ByteReader, it will be converted via a bufio.Reader. func newBitReader(r io.Reader) bitReader { - byter, ok := r.(byteReader) + byter, ok := r.(io.ByteReader) if !ok { byter = bufio.NewReader(r) } diff --git a/libgo/go/compress/flate/inflate.go b/libgo/go/compress/flate/inflate.go index c7ef5ff7e60..c5a54b998fa 100644 --- a/libgo/go/compress/flate/inflate.go +++ b/libgo/go/compress/flate/inflate.go @@ -208,8 +208,8 @@ type decompressor struct { h1, h2 huffmanDecoder // Length arrays used to define Huffman codes. - bits [maxLit + maxDist]int - codebits [numCodes]int + bits *[maxLit + maxDist]int + codebits *[numCodes]int // Output history, buffer. hist *[maxHist]byte @@ -692,6 +692,8 @@ func makeReader(r io.Reader) Reader { // finished reading. func NewReader(r io.Reader) io.ReadCloser { var f decompressor + f.bits = new([maxLit + maxDist]int) + f.codebits = new([numCodes]int) f.r = makeReader(r) f.hist = new([maxHist]byte) f.step = (*decompressor).nextBlock @@ -707,6 +709,8 @@ func NewReaderDict(r io.Reader, dict []byte) io.ReadCloser { var f decompressor f.r = makeReader(r) f.hist = new([maxHist]byte) + f.bits = new([maxLit + maxDist]int) + f.codebits = new([numCodes]int) f.step = (*decompressor).nextBlock f.setDict(dict) return &f |