Index: src/0dev.org/ioutil/ioutil.go ================================================================== --- src/0dev.org/ioutil/ioutil.go +++ src/0dev.org/ioutil/ioutil.go @@ -19,14 +19,14 @@ // Delegates the call to the WriterFunc while implementing io.Reader func (r ReaderFunc) Read(b []byte) (int, error) { return r(b) } -// Returns a reader that will delegate calls to Read(...) while ensuring -// that the output buffer will never be smaller than the required size -// and will be downsized to a multiple of the required size if larger -func BlockReader(reader io.Reader, size int) io.Reader { +// Returns a reader that delegates calls to Read(...) while ensuring +// that the output buffer is never smaller than the required size +// and is downsized to a multiple of the required size if larger +func SizedReader(reader io.Reader, size int) io.Reader { var buffer []byte = make([]byte, 0, size) return ReaderFunc(func(output []byte) (int, error) { var ( readCount int Index: src/0dev.org/ioutil/ioutil_test.go ================================================================== --- src/0dev.org/ioutil/ioutil_test.go +++ src/0dev.org/ioutil/ioutil_test.go @@ -51,11 +51,11 @@ var ( input []byte = []byte{0, 1, 2, 3, 4, 5, 6, 7} output []byte = make([]byte, 16) reader *bytes.Reader = bytes.NewReader(input) - min io.Reader = BlockReader(reader, 4) + min io.Reader = SizedReader(reader, 4) ) // Expecting a read count of 2 count, err := min.Read(output[:2]) if count != 2 { @@ -82,13 +82,13 @@ if err != nil { t.Error("Unexpected error from MinReader", err) } // Expecting a read count of 0 with an EOF as the buffer should be empty - count, err = min.Read(output[:4]) + count, err = min.Read(output[:1]) if count != 0 { t.Error("Invalid read count from MinReader", count) } if err != io.EOF { t.Error("Unexpected error from MinReader", err) } } Index: src/0dev.org/predictor/predictor.go ================================================================== --- src/0dev.org/predictor/predictor.go +++ src/0dev.org/predictor/predictor.go @@ -119,11 +119,11 @@ // and decompresses data according to the predictor algorithm func Decompressor(reader io.Reader) io.Reader { var ctx context ctx.input = make([]byte, 0, 8) - return iou.BlockReader(iou.ReaderFunc(func(output []byte) (int, error) { + return iou.SizedReader(iou.ReaderFunc(func(output []byte) (int, error) { var ( err error flags, predicted byte rc, total, copied int )