]> Cypherpunks repositories - gostls13.git/commitdiff
bufio: make Flush a no-op when the buffer is empty
authorAndrew Gerrand <adg@golang.org>
Mon, 31 Jan 2011 07:54:25 +0000 (18:54 +1100)
committerAndrew Gerrand <adg@golang.org>
Mon, 31 Jan 2011 07:54:25 +0000 (18:54 +1100)
R=r
CC=golang-dev
https://golang.org/cl/4119048

src/pkg/bufio/bufio.go

index 67b7cdb53c358a2d385d4bf7145895137fa94cd8..eae5c5ce9754e094ee85e1a92d074ba26d976e88 100644 (file)
@@ -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