]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use slices.SortStableFunc
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 4 Sep 2024 18:21:40 +0000 (01:21 +0700)
committerGopher Robot <gobot@golang.org>
Thu, 5 Sep 2024 18:56:40 +0000 (18:56 +0000)
Now that we're bootstrapping from a toolchain that has the slices
package.

Updates #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>
src/cmd/compile/internal/inline/inlheur/analyze.go
src/cmd/compile/internal/liveness/mergelocals.go

index 9ed7d73af98222e784a6e41f0c68a7f5e3e94cc6..2704f6a243c7c57383631f6e243dca8b9f210712 100644 (file)
@@ -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"
 )
 
@@ -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
 }
index d2a138c50e116e747ea623902a2ba371f65b85c0..cbe49aa65508380f8043fa2cffb4cd78c1b7d79c 100644 (file)
@@ -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
 }