]> Cypherpunks repositories - gostls13.git/commitdiff
strings: make Reader.Read use copy instead of an explicit loop.
authorNigel Tao <nigeltao@golang.org>
Sun, 15 May 2011 20:14:10 +0000 (13:14 -0700)
committerNigel Tao <nigeltao@golang.org>
Sun, 15 May 2011 20:14:10 +0000 (13:14 -0700)
R=r, bradfitz, r
CC=golang-dev
https://golang.org/cl/4529064

src/pkg/strings/reader.go

index 914faa00359916b1250852712babebdbb2850e1b..4eae90e73a46c78c77a126f736b1207601468cf0 100644 (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
 }