mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-05 00:47:51 -05:00
simplify writing
This commit is contained in:
parent
3df32aabbc
commit
0b388280ce
@ -140,17 +140,9 @@ func (w *BufferedWriter) Flush() error {
|
|||||||
w.buffer = nil
|
w.buffer = nil
|
||||||
|
|
||||||
if writer, ok := w.writer.(io.Writer); ok {
|
if writer, ok := w.writer.(io.Writer); ok {
|
||||||
defer b.Release()
|
err := WriteAllBytes(writer, b.Bytes())
|
||||||
|
b.Release()
|
||||||
for !b.IsEmpty() {
|
return err
|
||||||
n, err := writer.Write(b.Bytes())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
b.Advance(int32(n))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return w.writer.WriteMultiBuffer(NewMultiBufferValue(b))
|
return w.writer.WriteMultiBuffer(NewMultiBufferValue(b))
|
||||||
|
Loading…
Reference in New Issue
Block a user