mirror of
https://github.com/json-iterator/go.git
synced 2025-04-23 11:37:32 +02:00
ensure buffer flushed to io.Writer
This commit is contained in:
parent
4ae426c4b7
commit
6a4fbb9892
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user