all: Use some Go 1.21 features (#9409)

This commit is contained in:
Jakob Borg
2024-02-10 21:02:42 +01:00
committed by GitHub
parent 96c30f8387
commit e1dd36561d
13 changed files with 23 additions and 72 deletions
+3 -12
View File
@@ -12,6 +12,7 @@ import (
"hash/fnv"
"math/rand"
"net"
"slices"
stdsync "sync"
"time"
@@ -411,21 +412,11 @@ func addrSetsEqual(a []Address, b []Address) bool {
return false
}
// TODO: Rewrite this using slice.Contains once Go 1.21 is the minimum Go version.
for _, aElem := range a {
aElemFound := false
for _, bElem := range b {
if bElem.Equal(aElem) {
aElemFound = true
break
}
}
if !aElemFound {
// Found element in a that is not in b.
for _, v := range a {
if !slices.ContainsFunc(b, v.Equal) {
return false
}
}
// b contains all elements of a and their lengths are equal, so the sets are equal.
return true
}