diff options
Diffstat (limited to 'src/pkg/strings/strings.go')
| -rw-r--r-- | src/pkg/strings/strings.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/pkg/strings/strings.go b/src/pkg/strings/strings.go index 5d46211d84..53bcd6b98a 100644 --- a/src/pkg/strings/strings.go +++ b/src/pkg/strings/strings.go @@ -423,9 +423,10 @@ func Map(mapping func(rune) rune, s string) string { // Repeat returns a new string consisting of count copies of the string s. func Repeat(s string, count int) string { b := make([]byte, len(s)*count) - bp := 0 - for i := 0; i < count; i++ { - bp += copy(b[bp:], s) + bp := copy(b, s) + for bp < len(b) { + copy(b[bp:], b[:bp]) + bp *= 2 } return string(b) } |
