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:
parent
d49844bcce
commit
77d66f4131
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user