diff options
Diffstat (limited to 'libgo/go/bytes/buffer.go')
-rw-r--r-- | libgo/go/bytes/buffer.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libgo/go/bytes/buffer.go b/libgo/go/bytes/buffer.go index ddaba3b..9154a1b 100644 --- a/libgo/go/bytes/buffer.go +++ b/libgo/go/bytes/buffer.go @@ -17,8 +17,8 @@ import ( type Buffer struct { buf []byte // contents are the bytes buf[off : len(buf)] off int // read at &buf[off], write at &buf[len(buf)] - runeBytes [utf8.UTFMax]byte // avoid allocation of slice on each WriteByte or Rune - bootstrap [64]byte // memory to hold first slice; helps small buffers (Printf) avoid allocation. + runeBytes [utf8.UTFMax]byte // avoid allocation of slice on each call to WriteRune + bootstrap [64]byte // memory to hold first slice; helps small buffers avoid allocation. lastRead readOp // last read operation, so that Unread* can work correctly. } @@ -44,7 +44,7 @@ var ErrTooLarge = errors.New("bytes.Buffer: too large") func (b *Buffer) Bytes() []byte { return b.buf[b.off:] } // String returns the contents of the unread portion of the buffer -// as a string. If the Buffer is a nil pointer, it returns "<nil>". +// as a string. If the Buffer is a nil pointer, it returns "<nil>". func (b *Buffer) String() string { if b == nil { // Special case, useful in debugging. @@ -145,7 +145,7 @@ func (b *Buffer) WriteString(s string) (n int, err error) { } // MinRead is the minimum slice size passed to a Read call by -// Buffer.ReadFrom. As long as the Buffer has at least MinRead bytes beyond +// Buffer.ReadFrom. As long as the Buffer has at least MinRead bytes beyond // what is required to hold the contents of r, ReadFrom will not grow the // underlying buffer. const MinRead = 512 @@ -252,7 +252,7 @@ func (b *Buffer) WriteRune(r rune) (n int, err error) { } // Read reads the next len(p) bytes from the buffer or until the buffer -// is drained. The return value n is the number of bytes read. If the +// is drained. The return value n is the number of bytes read. If the // buffer has no data to return, err is io.EOF (unless len(p) is zero); // otherwise it is nil. func (b *Buffer) Read(p []byte) (n int, err error) { @@ -293,14 +293,14 @@ func (b *Buffer) Next(n int) []byte { // ReadByte reads and returns the next byte from the buffer. // If no byte is available, it returns error io.EOF. -func (b *Buffer) ReadByte() (c byte, err error) { +func (b *Buffer) ReadByte() (byte, error) { b.lastRead = opInvalid if b.off >= len(b.buf) { // Buffer is empty, reset to recover space. b.Truncate(0) return 0, io.EOF } - c = b.buf[b.off] + c := b.buf[b.off] b.off++ b.lastRead = opRead return c, nil @@ -347,7 +347,7 @@ func (b *Buffer) UnreadRune() error { } // UnreadByte unreads the last byte returned by the most recent -// read operation. If write has happened since the last read, UnreadByte +// read operation. If write has happened since the last read, UnreadByte // returns an error. func (b *Buffer) UnreadByte() error { if b.lastRead != opReadRune && b.lastRead != opRead { @@ -400,7 +400,7 @@ func (b *Buffer) ReadString(delim byte) (line string, err error) { } // NewBuffer creates and initializes a new Buffer using buf as its initial -// contents. It is intended to prepare a Buffer to read existing data. It +// contents. It is intended to prepare a Buffer to read existing data. It // can also be used to size the internal buffer for writing. To do that, // buf should have the desired capacity but a length of zero. // |