Skip to content

Commit

Permalink
Remove runtime/sam/expr.SortStable (#5137)
Browse files Browse the repository at this point in the history
slices.SortStableFunc does the same thing and should be faster since it
doesn't rely on sort.Interface.
  • Loading branch information
nwt authored Jun 7, 2024
1 parent 2037e11 commit 711bf9f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 0 additions & 6 deletions runtime/sam/expr/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,6 @@ func (s *sortStableReader) Read() (*zed.Value, error) {
return val, nil
}

// SortStable performs a stable sort on the provided records.
func SortStable(records []zed.Value, compare CompareFn) {
slice := &RecordSlice{records, compare}
sort.Stable(slice)
}

type RecordSlice struct {
vals []zed.Value
compare CompareFn
Expand Down
3 changes: 2 additions & 1 deletion runtime/sam/op/groupby/groupby.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/binary"
"errors"
"slices"
"sync"

"github.com/brimdata/zed"
Expand Down Expand Up @@ -246,7 +247,7 @@ func (o *Op) run() {
if res == nil {
break
}
expr.SortStable(res.Values(), o.agg.keyCompare)
slices.SortStableFunc(res.Values(), o.agg.keyCompare)
done, ok := o.sendResult(res, nil)
if !ok {
return
Expand Down

0 comments on commit 711bf9f

Please sign in to comment.