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:
cui fliter 2023-05-04 19:30:53 +08:00 committed by Gopher Robot
parent 5d76600cc0
commit 2ca4104f05
1 changed files with 2 additions and 13 deletions

View File

@ -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 {