1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-30 23:23:49 +02:00

#177 flush buffer should check available again

This commit is contained in:
Tao Wen
2017-09-21 21:04:45 +08:00
parent 46b20bbbec
commit dbb1ef3f63
2 changed files with 19 additions and 0 deletions

View File

@ -191,6 +191,9 @@ func (stream *Stream) ensure(minimal int) {
func (stream *Stream) growAtLeast(minimal int) {
if stream.out != nil {
stream.Flush()
if stream.Available() >= minimal {
return
}
}
toGrow := len(stream.buf)
if toGrow < minimal {