We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f51c2c9 commit b804acfCopy full SHA for b804acf
weightedrand.go
@@ -31,11 +31,10 @@ type Chooser struct {
31
32
// NewChooser initializes a new Chooser consisting of the possible Choices.
33
func NewChooser(cs ...Choice) Chooser {
34
- n := len(cs)
35
sort.Slice(cs, func(i, j int) bool {
36
return cs[i].Weight < cs[j].Weight
37
})
38
- totals := make([]int, n, n)
+ totals := make([]int, len(cs))
39
runningTotal := 0
40
for i, c := range cs {
41
runningTotal += int(c.Weight)
0 commit comments