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 {
return 0, os.EOF
}
for n < len(s) && n < len(b) {
b[n] = s[n]
n++
}
n = copy(b, s)
*r = s[n:]
return
}