Browse Source

ensure buffer flushed to io.Writer

Tao Wen 8 years ago
parent
commit
6a4fbb9892
1 changed files with 3 additions and 3 deletions
  1. 3 3
      feature_stream.go

+ 3 - 3
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