mirror of
https://github.com/json-iterator/go.git
synced 2025-04-26 11:42:56 +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) {
|
func (stream *Stream) ensure(minimal int) {
|
||||||
available := stream.Available()
|
available := stream.Available()
|
||||||
if available < minimal {
|
if available < minimal {
|
||||||
if stream.n > 1024 {
|
|
||||||
stream.Flush()
|
|
||||||
}
|
|
||||||
stream.growAtLeast(minimal)
|
stream.growAtLeast(minimal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (stream *Stream) growAtLeast(minimal int) {
|
func (stream *Stream) growAtLeast(minimal int) {
|
||||||
|
if stream.out != nil {
|
||||||
|
stream.Flush()
|
||||||
|
}
|
||||||
toGrow := len(stream.buf)
|
toGrow := len(stream.buf)
|
||||||
if toGrow < minimal {
|
if toGrow < minimal {
|
||||||
toGrow = minimal
|
toGrow = minimal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user