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:
parent
79b3daa977
commit
cc4bdf0226
@ -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) }},
|
||||
|
Loading…
Reference in New Issue
Block a user