diff --git a/src/pkg/bytes/bytes.go b/src/pkg/bytes/bytes.go index 405b10a1dbf00083ace24115697986774395ce04..01a5d9ae4ecaa7d5622efd2c4c8ff36beaf8807b 100644 --- a/src/pkg/bytes/bytes.go +++ b/src/pkg/bytes/bytes.go @@ -375,10 +375,7 @@ func Repeat(b []byte, count int) []byte { nb := make([]byte, len(b)*count) bp := 0 for i := 0; i < count; i++ { - for j := 0; j < len(b); j++ { - nb[bp] = b[j] - bp++ - } + bp += copy(nb[bp:], b) } return nb } diff --git a/src/pkg/strings/strings.go b/src/pkg/strings/strings.go index 4d33f1ecd7c79acddd06fca133a1a1b6bbf9a69b..5d46211d84e5e395ae0c7a0479c68f8ffcbda6db 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) }