From bb2a5f0556fd6bb4dbbce5eef2d6317d20796ade Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 21 May 2024 21:07:32 -0700 Subject: 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 Reviewed-by: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Reviewed-by: Damien Neil --- src/cmd/api/main_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/cmd/api/main_test.go') 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, ", ")) } -- cgit v1.3