diff options
| author | Josh Bleecher Snyder <josharian@gmail.com> | 2014-06-26 13:00:47 -0700 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2014-06-26 13:00:47 -0700 |
| commit | 548dece8f332fdfb55b78ebd678cb8f51207be95 (patch) | |
| tree | 9b2ad04c449cb896cad2027ca5922c603f5967a4 /src/pkg/strings | |
| parent | 07f6f313a90b264377f8a9ecc4fadfe13bfff633 (diff) | |
| download | go-548dece8f332fdfb55b78ebd678cb8f51207be95.tar.xz | |
strings: avoid pointless slice growth in makeBenchInputHard
LGTM=ruiu
R=golang-codereviews, ruiu
CC=golang-codereviews
https://golang.org/cl/108150043
Diffstat (limited to 'src/pkg/strings')
| -rw-r--r-- | src/pkg/strings/strings_test.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pkg/strings/strings_test.go b/src/pkg/strings/strings_test.go index 95102b56fa..27c0314fe8 100644 --- a/src/pkg/strings/strings_test.go +++ b/src/pkg/strings/strings_test.go @@ -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) |
