Commit 422da762 authored by Anthony Martin's avatar Anthony Martin

compress/bzip2: use io.ByteReader instead of internal interface

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6663044
parent 366268aa
...@@ -14,21 +14,16 @@ import ( ...@@ -14,21 +14,16 @@ import (
// because the error handling was verbose. Instead, any error is kept and can // because the error handling was verbose. Instead, any error is kept and can
// be checked afterwards. // be checked afterwards.
type bitReader struct { type bitReader struct {
r byteReader r io.ByteReader
n uint64 n uint64
bits uint bits uint
err error err error
} }
// bitReader needs to read bytes from an io.Reader. We attempt to convert the // newBitReader returns a new bitReader reading from r. If r is not
// given io.Reader to this interface and, if it doesn't already fit, we wrap in // already an io.ByteReader, it will be converted via a bufio.Reader.
// a bufio.Reader.
type byteReader interface {
ReadByte() (byte, error)
}
func newBitReader(r io.Reader) bitReader { func newBitReader(r io.Reader) bitReader {
byter, ok := r.(byteReader) byter, ok := r.(io.ByteReader)
if !ok { if !ok {
byter = bufio.NewReader(r) byter = bufio.NewReader(r)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment