Skip to content

Commit

Permalink
cmd/compile: use slices.SortStableFunc
Browse files Browse the repository at this point in the history
Now that we're bootstrapping from a toolchain that has the slices
package.

Updates golang#64751

Change-Id: I876ec6d261466344faf33f8c5cda229dd1e4185f
Reviewed-on: https://go-review.googlesource.com/c/go/+/610602
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
  • Loading branch information
cuonglm authored and gopherbot committed Sep 5, 2024
1 parent f15095f commit 32bd777
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/cmd/compile/internal/inline/inlheur/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/types"
"cmp"
"encoding/json"
"fmt"
"internal/buildcfg"
"io"
"os"
"path/filepath"
"sort"
"slices"
"strings"
)

Expand Down Expand Up @@ -349,11 +350,11 @@ func dumpFnPreamble(w io.Writer, funcInlHeur *fnInlHeur, ecst encodedCallSiteTab
// sortFnInlHeurSlice sorts a slice of fnInlHeur based on
// the starting line of the function definition, then by name.
func sortFnInlHeurSlice(sl []fnInlHeur) []fnInlHeur {
sort.SliceStable(sl, func(i, j int) bool {
if sl[i].line != sl[j].line {
return sl[i].line < sl[j].line
slices.SortStableFunc(sl, func(a, b fnInlHeur) int {
if a.line != b.line {
return cmp.Compare(a.line, b.line)
}
return sl[i].fname < sl[j].fname
return strings.Compare(a.fname, b.fname)
})
return sl
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/liveness/mergelocals.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func (mls *MergeLocalsState) Followers(n *ir.Name, tmp []*ir.Name) []*ir.Name {
for _, k := range sl[1:] {
tmp = append(tmp, mls.vars[k])
}
sort.SliceStable(tmp, func(i, j int) bool {
return tmp[i].Sym().Name < tmp[j].Sym().Name
slices.SortStableFunc(tmp, func(a, b *ir.Name) int {
return strings.Compare(a.Sym().Name, b.Sym().Name)
})
return tmp
}
Expand Down

0 comments on commit 32bd777

Please sign in to comment.