Skip to content

Commit 659902e

Browse files
committed
refactor: make use of slices.*
1 parent b5dad65 commit 659902e

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

language/js/generate_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"path"
66
"reflect"
7-
"sort"
7+
"slices"
88
"testing"
99
)
1010

@@ -160,8 +160,8 @@ func assertImports(t *testing.T, p string, expected []string) {
160160
actual := toImportPaths(p)
161161

162162
// Order doesn't matter so sort to ignore order
163-
sort.Strings(actual)
164-
sort.Strings(expected)
163+
slices.Sort(actual)
164+
slices.Sort(expected)
165165

166166
if !reflect.DeepEqual(actual, expected) {
167167
t.Errorf("toImportPaths('%s'): \nactual: %s\nexpected: %s\n", p, actual, expected)

language/js/proto/proto.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"io/ioutil"
66
"log"
77
"regexp"
8-
"sort"
8+
"slices"
99
"strconv"
1010
"strings"
1111

@@ -71,7 +71,7 @@ func GetProtoImports(filepath string) ([]string, error) {
7171
}
7272
}
7373

74-
sort.Strings(imports)
74+
slices.Sort(imports)
7575

7676
return imports, nil
7777
}

language/orion/generate.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"maps"
99
"path"
1010
"slices"
11-
"sort"
1211
"strings"
1312
"sync"
1413

@@ -380,7 +379,7 @@ func computeQueriesCacheKey(queries plugin.NamedQueries) string {
380379
for key := range queries {
381380
keys = append(keys, key)
382381
}
383-
sort.Strings(keys)
382+
slices.Sort(keys)
384383

385384
e := gob.NewEncoder(cacheDigest)
386385
for _, key := range keys {

language/orion/host.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"os"
1111
"path"
1212
"path/filepath"
13-
"sort"
13+
"slices"
1414
"strings"
1515

1616
"github.com/aspect-build/aspect-gazelle/common/bazel/workspace"
@@ -128,7 +128,7 @@ func (h *GazelleHost) loadEnvStarzellePlugins() {
128128
}
129129

130130
// Sort to ensure a consistent order not dependent on the fs or glob ordering.
131-
sort.Strings(builtinDirPlugins)
131+
slices.Sort(builtinDirPlugins)
132132

133133
builtinPlugins = append(builtinPlugins, builtinDirPlugins...)
134134
}

runner/bin/gazelle/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func parseArgs() (runner.GazelleCommand, runner.GazelleMode, bool, []string) {
9696

9797
func extractFlag(flag string, defaultValue bool, args []string) (bool, []string) {
9898
if i := slices.Index(args, flag); i != -1 {
99-
args = append(args[:i], args[i+1:]...)
99+
args = slices.Delete(args, i, i+1)
100100
return true, args
101101
}
102102

@@ -118,11 +118,11 @@ func extractArg(flag string, defaultValue string, args []string) (string, []stri
118118
return defaultValue, args
119119
}
120120
value := args[i+1]
121-
args = append(args[:i], args[i+2:]...)
121+
args = slices.Delete(args, i, i+2)
122122
return value, args
123123
}
124124

125125
_, value, _ := strings.Cut(args[i], "=")
126-
args = append(args[:i], args[i+1:]...)
126+
args = slices.Delete(args, i, i+1)
127127
return value, args
128128
}

0 commit comments

Comments
 (0)