Skip to content

Commit

Permalink
cmd/asm/internal: use slices.Contains
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tklauser authored and gopherbot committed Sep 6, 2024
1 parent 12dcbed commit e6ae2d8
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/cmd/asm/internal/lex/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"strconv"
"strings"
"text/scanner"
Expand Down Expand Up @@ -252,7 +253,7 @@ func (in *Input) macroDefinition(name string) ([]string, []Token) {
in.Error("bad syntax in definition for macro:", name)
}
arg := in.Stack.Text()
if i := lookup(args, arg); i >= 0 {
if slices.Contains(args, arg) {
in.Error("duplicate argument", arg, "in definition for macro:", name)
}
args = append(args, arg)
Expand Down Expand Up @@ -280,15 +281,6 @@ func (in *Input) macroDefinition(name string) ([]string, []Token) {
return args, tokens
}

func lookup(args []string, arg string) int {
for i, a := range args {
if a == arg {
return i
}
}
return -1
}

// invokeMacro pushes onto the input Stack a Slice that holds the macro definition with the actual
// parameters substituted for the formals.
// Invoking a macro does not touch the PC/line history.
Expand Down

0 comments on commit e6ae2d8

Please sign in to comment.