mirror of https://github.com/golang/go.git
cmd: use slices.Equal to simplify code
#57433 added slices.Equal, using it can reduce the amount of code Change-Id: I70d14b6c4c24da641a34ed36c900d9291033f526 Reviewed-on: https://go-review.googlesource.com/c/go/+/492576 Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: shuang cui <imcusg@gmail.com>
This commit is contained in:
parent
5d76600cc0
commit
2ca4104f05
|
|
@ -6,6 +6,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
|
|
@ -20,25 +21,13 @@ type argstate struct {
|
|||
initialized bool
|
||||
}
|
||||
|
||||
func ssleq(s1 []string, s2 []string) bool {
|
||||
if len(s1) != len(s2) {
|
||||
return false
|
||||
}
|
||||
for i := range s1 {
|
||||
if s1[i] != s2[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (a *argstate) Merge(state argvalues) {
|
||||
if !a.initialized {
|
||||
a.state = state
|
||||
a.initialized = true
|
||||
return
|
||||
}
|
||||
if !ssleq(a.state.osargs, state.osargs) {
|
||||
if !slices.Equal(a.state.osargs, state.osargs) {
|
||||
a.state.osargs = nil
|
||||
}
|
||||
if state.goos != a.state.goos {
|
||||
|
|
|
|||
Loading…
Reference in New Issue