Commit d166a369 authored by Matt Layher's avatar Matt Layher Committed by Brad Fitzpatrick

bufio: remove redundant Writer.flush method

Fixes #17232

Change-Id: I34df86f79b643dce9f054c6df6782e6037c06910
Reviewed-on: https://go-review.googlesource.com/30158
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 05f59959
......@@ -549,11 +549,6 @@ func (b *Writer) Reset(w io.Writer) {
// Flush writes any buffered data to the underlying io.Writer.
func (b *Writer) Flush() error {
err := b.flush()
return err
}
func (b *Writer) flush() error {
if b.err != nil {
return b.err
}
......@@ -596,7 +591,7 @@ func (b *Writer) Write(p []byte) (nn int, err error) {
} else {
n = copy(b.buf[b.n:], p)
b.n += n
b.flush()
b.Flush()
}
nn += n
p = p[n:]
......@@ -615,7 +610,7 @@ func (b *Writer) WriteByte(c byte) error {
if b.err != nil {
return b.err
}
if b.Available() <= 0 && b.flush() != nil {
if b.Available() <= 0 && b.Flush() != nil {
return b.err
}
b.buf[b.n] = c
......@@ -638,7 +633,7 @@ func (b *Writer) WriteRune(r rune) (size int, err error) {
}
n := b.Available()
if n < utf8.UTFMax {
if b.flush(); b.err != nil {
if b.Flush(); b.err != nil {
return 0, b.err
}
n = b.Available()
......@@ -663,7 +658,7 @@ func (b *Writer) WriteString(s string) (int, error) {
b.n += n
nn += n
s = s[n:]
b.flush()
b.Flush()
}
if b.err != nil {
return nn, b.err
......@@ -684,7 +679,7 @@ func (b *Writer) ReadFrom(r io.Reader) (n int64, err error) {
var m int
for {
if b.Available() == 0 {
if err1 := b.flush(); err1 != nil {
if err1 := b.Flush(); err1 != nil {
return n, err1
}
}
......@@ -708,7 +703,7 @@ func (b *Writer) ReadFrom(r io.Reader) (n int64, err error) {
if err == io.EOF {
// If we filled the buffer exactly, flush preemptively.
if b.Available() == 0 {
err = b.flush()
err = b.Flush()
} else {
err = nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment