1
0
mirror of https://github.com/golang/go synced 2024-11-22 02:24:41 -07:00

bufio: make Flush a no-op when the buffer is empty

R=r
CC=golang-dev
https://golang.org/cl/4119048
This commit is contained in:
Andrew Gerrand 2011-01-31 18:54:25 +11:00
parent 3bfd35b72e
commit 9173a09530

View File

@ -385,6 +385,9 @@ func (b *Writer) Flush() os.Error {
if b.err != nil { if b.err != nil {
return b.err return b.err
} }
if b.n == 0 {
return nil
}
n, e := b.wr.Write(b.buf[0:b.n]) n, e := b.wr.Write(b.buf[0:b.n])
if n < b.n && e == nil { if n < b.n && e == nil {
e = io.ErrShortWrite e = io.ErrShortWrite