1
0
mirror of https://github.com/golang/go synced 2024-11-19 22:24:49 -07:00

strings: make Reader.Read use copy instead of an explicit loop.

R=r, bradfitz, r
CC=golang-dev
https://golang.org/cl/4529064
This commit is contained in:
Nigel Tao 2011-05-15 13:14:10 -07:00
parent d49844bcce
commit 77d66f4131

View File

@ -18,10 +18,7 @@ func (r *Reader) Read(b []byte) (n int, err os.Error) {
if len(s) == 0 { if len(s) == 0 {
return 0, os.EOF return 0, os.EOF
} }
for n < len(s) && n < len(b) { n = copy(b, s)
b[n] = s[n]
n++
}
*r = s[n:] *r = s[n:]
return return
} }