Skip to content

Commit

Permalink
cmd: use slices.Equal to simplify code
Browse files Browse the repository at this point in the history
#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>
  • Loading branch information
cuishuang authored and gopherbot committed May 10, 2023
1 parent 5d76600 commit 2ca4104
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/cmd/covdata/argsmerge.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package main

import (
"fmt"
"slices"
"strconv"
)

Expand All @@ -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 {
Expand Down

0 comments on commit 2ca4104

Please sign in to comment.