1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-03 07:56:42 -05:00

simplify writing

This commit is contained in:
Darien Raymond 2018-08-29 16:42:03 +02:00
parent 3df32aabbc
commit 0b388280ce
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -140,17 +140,9 @@ func (w *BufferedWriter) Flush() error {
w.buffer = nil
if writer, ok := w.writer.(io.Writer); ok {
defer b.Release()
for !b.IsEmpty() {
n, err := writer.Write(b.Bytes())
if err != nil {
return err
}
b.Advance(int32(n))
}
return nil
err := WriteAllBytes(writer, b.Bytes())
b.Release()
return err
}
return w.writer.WriteMultiBuffer(NewMultiBufferValue(b))