1
0
mirror of https://github.com/golang/go synced 2024-11-18 08:44:43 -07:00

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
This commit is contained in:
Rui Ueyama 2014-03-19 12:13:47 -07:00 committed by Brad Fitzpatrick
parent 79b3daa977
commit cc4bdf0226
4 changed files with 0 additions and 4 deletions

View File

@ -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")
}

View File

@ -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) }},

View File

@ -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")
}

View File

@ -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) }},