Commit cc4bdf02 authored by Rui Ueyama's avatar Rui Ueyama Committed by Brad Fitzpatrick

strings, bytes: ReadAt should not mutate receiver

CL 77580046 caused a data race issue with tests that assumes ReadAt
does not mutate receiver. This patch partially revert CL 77580046
to fix it.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/77900043
parent 79b3daa9
......@@ -43,7 +43,6 @@ func (r *Reader) Read(b []byte) (n int, err error) {
}
func (r *Reader) ReadAt(b []byte, off int64) (n int, err error) {
r.prevRune = -1
if off < 0 {
return 0, errors.New("bytes: invalid offset")
}
......
......@@ -138,7 +138,6 @@ var UnreadRuneErrorTests = []struct {
f func(*Reader)
}{
{"Read", func(r *Reader) { r.Read([]byte{}) }},
{"ReadAt", func(r *Reader) { r.ReadAt([]byte{}, 0) }},
{"ReadByte", func(r *Reader) { r.ReadByte() }},
{"UnreadRune", func(r *Reader) { r.UnreadRune() }},
{"Seek", func(r *Reader) { r.Seek(0, 1) }},
......
......@@ -42,7 +42,6 @@ func (r *Reader) Read(b []byte) (n int, err error) {
}
func (r *Reader) ReadAt(b []byte, off int64) (n int, err error) {
r.prevRune = -1
if off < 0 {
return 0, errors.New("strings: invalid offset")
}
......
......@@ -863,7 +863,6 @@ var UnreadRuneErrorTests = []struct {
f func(*Reader)
}{
{"Read", func(r *Reader) { r.Read([]byte{}) }},
{"ReadAt", func(r *Reader) { r.ReadAt([]byte{}, 0) }},
{"ReadByte", func(r *Reader) { r.ReadByte() }},
{"UnreadRune", func(r *Reader) { r.UnreadRune() }},
{"Seek", func(r *Reader) { r.Seek(0, 1) }},
......
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