Skip to content

Commit

Permalink
chore: trivial syntax simplification in NewChooser
Browse files Browse the repository at this point in the history
  • Loading branch information
mroth committed Sep 15, 2019
1 parent f51c2c9 commit b804acf
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions weightedrand.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ type Chooser struct {

// NewChooser initializes a new Chooser consisting of the possible Choices.
func NewChooser(cs ...Choice) Chooser {
n := len(cs)
sort.Slice(cs, func(i, j int) bool {
return cs[i].Weight < cs[j].Weight
})
totals := make([]int, n, n)
totals := make([]int, len(cs))
runningTotal := 0
for i, c := range cs {
runningTotal += int(c.Weight)
Expand Down

0 comments on commit b804acf

Please sign in to comment.