]> Cypherpunks repositories - gostls13.git/commitdiff
Conversion from loop to copy().
authorKyle Consalus <consalus@gmail.com>
Wed, 5 May 2010 16:57:53 +0000 (09:57 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 5 May 2010 16:57:53 +0000 (09:57 -0700)
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/1072041

src/pkg/strings/strings.go

index 90417f811d060c25163ef1a93377c8a9afafd2ba..b6d84d07aaf87838053b1422fafbe521476b7fdd 100644 (file)
@@ -275,9 +275,7 @@ func Map(mapping func(rune int) int, s string) string {
                                // Grow the buffer.
                                maxbytes = maxbytes*2 + utf8.UTFMax
                                nb := make([]byte, maxbytes)
-                               for i, c := range b[0:nbytes] {
-                                       nb[i] = c
-                               }
+                               copy(nb, b[0:nbytes])
                                b = nb
                        }
                        nbytes += utf8.EncodeRune(rune, b[nbytes:maxbytes])