From 6a4fbb9892c50d930834e09be2d8a339b4fff3e2 Mon Sep 17 00:00:00 2001 From: Tao Wen Date: Sun, 16 Jul 2017 10:47:24 +0800 Subject: [PATCH] ensure buffer flushed to io.Writer --- feature_stream.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/feature_stream.go b/feature_stream.go index f4fa385..9c8470a 100644 --- a/feature_stream.go +++ b/feature_stream.go @@ -184,14 +184,14 @@ func (stream *Stream) Flush() error { func (stream *Stream) ensure(minimal int) { available := stream.Available() if available < minimal { - if stream.n > 1024 { - stream.Flush() - } stream.growAtLeast(minimal) } } func (stream *Stream) growAtLeast(minimal int) { + if stream.out != nil { + stream.Flush() + } toGrow := len(stream.buf) if toGrow < minimal { toGrow = minimal