aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2011-01-31 18:54:25 +1100
committerAndrew Gerrand <adg@golang.org>2011-01-31 18:54:25 +1100
commit9173a095300ad4a1d0e57b4d096c39a655753382 (patch)
tree52996afb477e6f61979c2f2a23197ea4007d35ae
parent3bfd35b72e24ec5c918a9e0f233634db45950c68 (diff)
downloadgo-9173a095300ad4a1d0e57b4d096c39a655753382.tar.gz
go-9173a095300ad4a1d0e57b4d096c39a655753382.zip
bufio: make Flush a no-op when the buffer is empty
R=r CC=golang-dev https://golang.org/cl/4119048
-rw-r--r--src/pkg/bufio/bufio.go3
1 files changed, 3 insertions, 0 deletions
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