Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using slices.Contains #13835

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions container/slice/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package slice

import (
"fmt"
"slices"
"strings"

"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
Expand Down Expand Up @@ -140,12 +141,7 @@ func NotUint64(a, b []uint64) []uint64 {

// IsInUint64 returns true if a is in b and False otherwise.
func IsInUint64(a uint64, b []uint64) bool {
for _, v := range b {
if a == v {
return true
}
}
return false
return slices.Contains(b, a)
}

// IntersectionInt64 of any number of int64 slices with time
Expand Down Expand Up @@ -226,12 +222,7 @@ func NotInt64(a, b []int64) []int64 {

// IsInInt64 returns true if a is in b and False otherwise.
func IsInInt64(a int64, b []int64) bool {
for _, v := range b {
if a == v {
return true
}
}
return false
return slices.Contains(b, a)
}

// UnionByteSlices returns the all elements between sets of byte slices.
Expand Down Expand Up @@ -358,12 +349,7 @@ func NotSlot(a, b []primitives.Slot) []primitives.Slot {

// IsInSlots returns true if a is in b and False otherwise.
func IsInSlots(a primitives.Slot, b []primitives.Slot) bool {
for _, v := range b {
if a == v {
return true
}
}
return false
return slices.Contains(b, a)
}

// Unique returns an array with duplicates filtered based on the type given
Expand Down
Loading