Skip to content

Commit 459cb83

Browse files
committed
Address review comments
1 parent b46c562 commit 459cb83

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mem/buffer_slice.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ func NewWriter(buffers *BufferSlice, pool BufferPool) io.Writer {
238238
// buffers. It is the responsibility of the caller to free this buffer.
239239
func ReadAll(r io.Reader, pool BufferPool) (BufferSlice, error) {
240240
var result BufferSlice
241-
wt, ok := r.(io.WriterTo)
242-
if ok {
241+
if wt, ok := r.(io.WriterTo); ok {
243242
// This is more optimal since wt knows the size of chunks it wants to
244243
// write and, hence, we can allocate buffers of an optimal size to fit
245244
// them. E.g. might be a single big chunk, and we wouldn't chop it
@@ -248,6 +247,7 @@ func ReadAll(r io.Reader, pool BufferPool) (BufferSlice, error) {
248247
_, err := wt.WriteTo(w)
249248
return result, err
250249
}
250+
nextBuffer:
251251
for {
252252
buf := pool.Get(readAllBufSize)
253253
// We asked for 32KiB but may have been given a bigger buffer.
@@ -272,7 +272,7 @@ func ReadAll(r io.Reader, pool BufferPool) (BufferSlice, error) {
272272
}
273273
if len(*buf) == usedCap {
274274
result = append(result, NewBuffer(buf, pool))
275-
break // grab a new buf from pool
275+
continue nextBuffer
276276
}
277277
}
278278
}

0 commit comments

Comments
 (0)