You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-24 23:16:47 +02:00
ensure buffer flushed to io.Writer
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user