Skip to content

Commit b804acf

Browse files
committed
chore: trivial syntax simplification in NewChooser
1 parent f51c2c9 commit b804acf

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

weightedrand.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ type Chooser struct {
3131

3232
// NewChooser initializes a new Chooser consisting of the possible Choices.
3333
func NewChooser(cs ...Choice) Chooser {
34-
n := len(cs)
3534
sort.Slice(cs, func(i, j int) bool {
3635
return cs[i].Weight < cs[j].Weight
3736
})
38-
totals := make([]int, n, n)
37+
totals := make([]int, len(cs))
3938
runningTotal := 0
4039
for i, c := range cs {
4140
runningTotal += int(c.Weight)

0 commit comments

Comments
 (0)