aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/api
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2024-05-21 21:07:32 -0700
committerGopher Robot <gobot@golang.org>2024-11-18 19:38:28 +0000
commitbb2a5f0556fd6bb4dbbce5eef2d6317d20796ade (patch)
tree74478d496a849532e5095877b2e098036c2921e5 /src/cmd/api
parent80344887818a2321296ce7fa71cca8ca2520611d (diff)
downloadgo-bb2a5f0556fd6bb4dbbce5eef2d6317d20796ade.tar.xz
cmd: change from sort functions to slices functions
Doing this because the slices functions are slightly faster and slightly easier to use. It also removes one dependency layer. We did this outside of bootstrap tools in CL 587655. Now that the bootstrap compiler is 1.22, we can do this in more code. Change-Id: I9ed2dd473758cacd14f76a0639368523ccdff72f Reviewed-on: https://go-review.googlesource.com/c/go/+/626038 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/cmd/api')
-rw-r--r--src/cmd/api/api_test.go4
-rw-r--r--src/cmd/api/main_test.go18
2 files changed, 11 insertions, 11 deletions
diff --git a/src/cmd/api/api_test.go b/src/cmd/api/api_test.go
index ba358d364d..7848233333 100644
--- a/src/cmd/api/api_test.go
+++ b/src/cmd/api/api_test.go
@@ -11,7 +11,7 @@ import (
"internal/testenv"
"os"
"path/filepath"
- "sort"
+ "slices"
"strings"
"sync"
"testing"
@@ -77,7 +77,7 @@ func TestGolden(t *testing.T) {
t.Fatalf("opening golden.txt for package %q: %v", fi.Name(), err)
}
wanted := strings.Split(string(bs), "\n")
- sort.Strings(wanted)
+ slices.Sort(wanted)
for _, feature := range wanted {
if feature == "" {
continue
diff --git a/src/cmd/api/main_test.go b/src/cmd/api/main_test.go
index 10dbabb9b8..a0820c2274 100644
--- a/src/cmd/api/main_test.go
+++ b/src/cmd/api/main_test.go
@@ -25,7 +25,7 @@ import (
"path/filepath"
"regexp"
"runtime"
- "sort"
+ "slices"
"strconv"
"strings"
"sync"
@@ -232,8 +232,8 @@ func compareAPI(w io.Writer, features, required, exception []string) (ok bool) {
featureSet := set(features)
exceptionSet := set(exception)
- sort.Strings(features)
- sort.Strings(required)
+ slices.Sort(features)
+ slices.Sort(required)
take := func(sl *[]string) string {
s := (*sl)[0]
@@ -378,7 +378,7 @@ func (w *Walker) Features() (fs []string) {
for f := range w.features {
fs = append(fs, f)
}
- sort.Strings(fs)
+ slices.Sort(fs)
return
}
@@ -431,7 +431,7 @@ func tagKey(dir string, context *build.Context, tags []string) string {
// an indirect imported package. See https://github.com/golang/go/issues/21181
// for more detail.
tags = append(tags, context.GOOS, context.GOARCH)
- sort.Strings(tags)
+ slices.Sort(tags)
for _, tag := range tags {
if ctags[tag] {
@@ -535,7 +535,7 @@ func (w *Walker) loadImports() {
}
}
- sort.Strings(stdPackages)
+ slices.Sort(stdPackages)
imports = listImports{
stdPackages: stdPackages,
importMap: importMap,
@@ -717,7 +717,7 @@ func sortedMethodNames(typ *types.Interface) []string {
for i := range list {
list[i] = typ.Method(i).Name()
}
- sort.Strings(list)
+ slices.Sort(list)
return list
}
@@ -747,7 +747,7 @@ func (w *Walker) sortedEmbeddeds(typ *types.Interface) []string {
list = append(list, buf.String())
}
}
- sort.Strings(list)
+ slices.Sort(list)
return list
}
@@ -1083,7 +1083,7 @@ func (w *Walker) emitIfaceType(name string, typ *types.Interface) {
return
}
- sort.Strings(methodNames)
+ slices.Sort(methodNames)
w.emitf("type %s interface { %s }", name, strings.Join(methodNames, ", "))
}