Skip to content

Commit

Permalink
Revert "bufio: make Reader.Peek invalidate Unreads"
Browse files Browse the repository at this point in the history
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 ae23868.

Change-Id: Ib67b8629e3deac5d50d76581aba6a91ca7a7853e
Reviewed-on: https://go-review.googlesource.com/47570
Reviewed-by: Russ Cox <[email protected]>
  • Loading branch information
rsc committed Jul 6, 2017
1 parent b5240da commit e71285c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
3 changes: 0 additions & 3 deletions src/bufio/bufio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
18 changes: 0 additions & 18 deletions src/bufio/bufio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit e71285c

Please sign in to comment.