diff options
| author | Evan Shaw <chickencha@gmail.com> | 2013-08-27 09:21:08 +1000 |
|---|---|---|
| committer | Andrew Gerrand <adg@golang.org> | 2013-08-27 09:21:08 +1000 |
| commit | f033d988b1926215f59aa1eee37c05e59adbac02 (patch) | |
| tree | da678982adbbd376f324f493530e8aa643bac1f3 /src/pkg/strings | |
| parent | b2e937970b27386951fac2e8d03015c62276a19c (diff) | |
| download | go-f033d988b1926215f59aa1eee37c05e59adbac02.tar.xz | |
bytes, strings: use copy in Repeat
R=golang-dev, dave, bradfitz, adg
CC=golang-dev
https://golang.org/cl/13249043
Diffstat (limited to 'src/pkg/strings')
| -rw-r--r-- | src/pkg/strings/strings.go | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/pkg/strings/strings.go b/src/pkg/strings/strings.go index 4d33f1ecd7..5d46211d84 100644 --- a/src/pkg/strings/strings.go +++ b/src/pkg/strings/strings.go @@ -425,10 +425,7 @@ func Repeat(s string, count int) string { b := make([]byte, len(s)*count) bp := 0 for i := 0; i < count; i++ { - for j := 0; j < len(s); j++ { - b[bp] = s[j] - bp++ - } + bp += copy(b[bp:], s) } return string(b) } |
