From: Andrew Gerrand Date: Mon, 31 Jan 2011 07:54:25 +0000 (+1100) Subject: bufio: make Flush a no-op when the buffer is empty X-Git-Tag: weekly.2011-02-01~38 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9173a095300ad4a1d0e57b4d096c39a655753382;p=gostls13.git bufio: make Flush a no-op when the buffer is empty R=r CC=golang-dev https://golang.org/cl/4119048 --- diff --git a/src/pkg/bufio/bufio.go b/src/pkg/bufio/bufio.go index 67b7cdb53c..eae5c5ce97 100644 --- a/src/pkg/bufio/bufio.go +++ b/src/pkg/bufio/bufio.go @@ -385,6 +385,9 @@ func (b *Writer) Flush() os.Error { if b.err != nil { return b.err } + if b.n == 0 { + return nil + } n, e := b.wr.Write(b.buf[0:b.n]) if n < b.n && e == nil { e = io.ErrShortWrite