]> Cypherpunks repositories - gostls13.git/commitdiff
cmd: use slices.Equal to simplify code
authorcui fliter <imcusg@gmail.com>
Thu, 4 May 2023 11:30:53 +0000 (19:30 +0800)
committerGopher Robot <gobot@golang.org>
Wed, 10 May 2023 10:18:37 +0000 (10:18 +0000)
#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>

src/cmd/covdata/argsmerge.go

index f591e3abd4049c8bae97b54863ca9c5d61fc7609..8af1432d62ad3077f703f8dd59931e11cdc41e17 100644 (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 {