From 9173a095300ad4a1d0e57b4d096c39a655753382 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Mon, 31 Jan 2011 18:54:25 +1100 Subject: [PATCH] bufio: make Flush a no-op when the buffer is empty R=r CC=golang-dev https://golang.org/cl/4119048 --- src/pkg/bufio/bufio.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pkg/bufio/bufio.go b/src/pkg/bufio/bufio.go index 67b7cdb53c3..eae5c5ce975 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