Commit e71285c4 authored by Russ Cox's avatar Russ Cox

Revert "bufio: make Reader.Peek invalidate Unreads"

Go 1.9 beta 2 is already out.
It's too late to break code with a change like this.
This can be rolled forward for Go 1.10.

This reverts commit ae238688.

Change-Id: Ib67b8629e3deac5d50d76581aba6a91ca7a7853e
Reviewed-on: https://go-review.googlesource.com/47570Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent b5240daa
......@@ -125,9 +125,6 @@ func (b *Reader) Peek(n int) ([]byte, error) {
return nil, ErrNegativeCount
}
b.lastByte = -1
b.lastRuneSize = -1
for b.w-b.r < n && b.w-b.r < len(b.buf) && b.err == nil {
b.fill() // b.w-b.r < len(b.buf) => buffer is not full
}
......
......@@ -285,24 +285,6 @@ func TestUnreadRune(t *testing.T) {
}
}
func TestNoUnreadRuneAfterPeek(t *testing.T) {
br := NewReader(strings.NewReader("example"))
br.ReadRune()
br.Peek(1)
if err := br.UnreadRune(); err == nil {
t.Error("UnreadRune didn't fail after Peek")
}
}
func TestNoUnreadByteAfterPeek(t *testing.T) {
br := NewReader(strings.NewReader("example"))
br.ReadByte()
br.Peek(1)
if err := br.UnreadByte(); err == nil {
t.Error("UnreadByte didn't fail after Peek")
}
}
func TestUnreadByte(t *testing.T) {
segments := []string{"Hello, ", "world"}
r := NewReader(&StringReader{data: segments})
......
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