Skip to content

Commit e6ae2d8

Browse files
tklausergopherbot
authored andcommitted
cmd/asm/internal: use slices.Contains
Now that Go 1.22.6 is the minimum bootstrap toolchain (cf. CL 606156), the slices package (introduced in Go 1.21) can be used in packages built using the bootstrap toolchain. For #64751 Change-Id: I0115213da4b1f0a1fa0ef7ad34456fbf52e00fae Reviewed-on: https://go-review.googlesource.com/c/go/+/611095 Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Tobias Klauser <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 12dcbed commit e6ae2d8

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/cmd/asm/internal/lex/input.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"os"
1010
"path/filepath"
11+
"slices"
1112
"strconv"
1213
"strings"
1314
"text/scanner"
@@ -252,7 +253,7 @@ func (in *Input) macroDefinition(name string) ([]string, []Token) {
252253
in.Error("bad syntax in definition for macro:", name)
253254
}
254255
arg := in.Stack.Text()
255-
if i := lookup(args, arg); i >= 0 {
256+
if slices.Contains(args, arg) {
256257
in.Error("duplicate argument", arg, "in definition for macro:", name)
257258
}
258259
args = append(args, arg)
@@ -280,15 +281,6 @@ func (in *Input) macroDefinition(name string) ([]string, []Token) {
280281
return args, tokens
281282
}
282283

283-
func lookup(args []string, arg string) int {
284-
for i, a := range args {
285-
if a == arg {
286-
return i
287-
}
288-
}
289-
return -1
290-
}
291-
292284
// invokeMacro pushes onto the input Stack a Slice that holds the macro definition with the actual
293285
// parameters substituted for the formals.
294286
// Invoking a macro does not touch the PC/line history.

0 commit comments

Comments
 (0)