From afcad409e241af790cc4522563ec852566aebf2f Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Fri, 17 Nov 2017 09:18:12 +0000 Subject: [PATCH] reallocate in for loop --- common/buf/writer.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/buf/writer.go b/common/buf/writer.go index 50ecbb8c0..581a8668b 100644 --- a/common/buf/writer.go +++ b/common/buf/writer.go @@ -60,12 +60,12 @@ func (w *BufferedWriter) Write(b []byte) (int, error) { return w.legacyWriter.Write(b) } - if w.buffer == nil { - w.buffer = New() - } - totalBytes := 0 for len(b) > 0 { + if w.buffer == nil { + w.buffer = New() + } + nBytes, err := w.buffer.Write(b) totalBytes += nBytes if err != nil {