Skip to content

Commit

Permalink
Make it slightly faster by removing sort
Browse files Browse the repository at this point in the history
  • Loading branch information
haccht committed Nov 10, 2023
1 parent a192f71 commit 3ea939b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"io"
"os"
"sort"
"slices"
"strconv"
"strings"
"text/tabwriter"
Expand Down Expand Up @@ -64,15 +64,12 @@ func run() error {
return nil
}

sort.Float64s(vals)

min := vals[0]
max := vals[len(vals)-1]
min := slices.Min(vals)
max := slices.Max(vals)
w := (max - min) / float64(opts.Bins)

var mcount int
bins := make([]int, opts.Bins, opts.Bins)

for _, val := range vals {
var idx int
if val != max {
Expand Down

0 comments on commit 3ea939b

Please sign in to comment.