Commit f033d988 authored by Evan Shaw's avatar Evan Shaw Committed by Andrew Gerrand

bytes, strings: use copy in Repeat

R=golang-dev, dave, bradfitz, adg
CC=golang-dev
https://golang.org/cl/13249043
parent b2e93797
......@@ -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
}
......
......@@ -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)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment