Skip to content

Commit 2ca4104

Browse files
cuishuanggopherbot
authored andcommitted
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 <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Run-TryBot: shuang cui <[email protected]>
1 parent 5d76600 commit 2ca4104

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/cmd/covdata/argsmerge.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package main
66

77
import (
88
"fmt"
9+
"slices"
910
"strconv"
1011
)
1112

@@ -20,25 +21,13 @@ type argstate struct {
2021
initialized bool
2122
}
2223

23-
func ssleq(s1 []string, s2 []string) bool {
24-
if len(s1) != len(s2) {
25-
return false
26-
}
27-
for i := range s1 {
28-
if s1[i] != s2[i] {
29-
return false
30-
}
31-
}
32-
return true
33-
}
34-
3524
func (a *argstate) Merge(state argvalues) {
3625
if !a.initialized {
3726
a.state = state
3827
a.initialized = true
3928
return
4029
}
41-
if !ssleq(a.state.osargs, state.osargs) {
30+
if !slices.Equal(a.state.osargs, state.osargs) {
4231
a.state.osargs = nil
4332
}
4433
if state.goos != a.state.goos {

0 commit comments

Comments
 (0)