From 0b388280ce5b5cc960909e35a7476cc1ab44d626 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Wed, 29 Aug 2018 16:42:03 +0200 Subject: [PATCH] simplify writing --- common/buf/writer.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/common/buf/writer.go b/common/buf/writer.go index 51b104641..66d24b0e2 100644 --- a/common/buf/writer.go +++ b/common/buf/writer.go @@ -140,17 +140,9 @@ func (w *BufferedWriter) Flush() error { w.buffer = nil if writer, ok := w.writer.(io.Writer); ok { - defer b.Release() - - for !b.IsEmpty() { - n, err := writer.Write(b.Bytes()) - if err != nil { - return err - } - b.Advance(int32(n)) - } - - return nil + err := WriteAllBytes(writer, b.Bytes()) + b.Release() + return err } return w.writer.WriteMultiBuffer(NewMultiBufferValue(b))