Skip to content

bufio.Writer.Write() optimization error (and a trivial fix) #949

@msolo

Description

@msolo
bufio.Writer.Write() has an optimization to pass writes larger than the buffer size
directly to the underlying writer. However, there is a bug.  At first it looks sinister,
but really it just disables the optimization.

diff -r af73f0550913 src/pkg/bufio/bufio.go
--- a/src/pkg/bufio/bufio.go    Fri Jul 23 12:34:35 2010 -0700
+++ b/src/pkg/bufio/bufio.go    Fri Jul 23 17:54:02 2010 -0700
@@ -392,7 +392,8 @@
            }
            n = b.Available()
        }
-       if b.Available() == 0 && len(p) >= len(b.buf) {
+       if b.Buffered() == 0 && len(p) >= len(b.buf) {

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions