mirror of
https://github.com/golang/go
synced 2024-11-24 06:00:11 -07:00
strings: avoid pointless slice growth in makeBenchInputHard
LGTM=ruiu R=golang-codereviews, ruiu CC=golang-codereviews https://golang.org/cl/108150043
This commit is contained in:
parent
07f6f313a9
commit
548dece8f3
@ -1069,8 +1069,11 @@ func makeBenchInputHard() string {
|
||||
"hello", "world",
|
||||
}
|
||||
x := make([]byte, 0, 1<<20)
|
||||
for len(x) < 1<<20 {
|
||||
for {
|
||||
i := rand.Intn(len(tokens))
|
||||
if len(x)+len(tokens[i]) >= 1<<20 {
|
||||
break
|
||||
}
|
||||
x = append(x, tokens[i]...)
|
||||
}
|
||||
return string(x)
|
||||
|
Loading…
Reference in New Issue
Block a user