mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
p2p: using slices.ContainsFunc
This commit is contained in:
parent
a3829178af
commit
ab0738fd7f
1 changed files with 4 additions and 6 deletions
10
p2p/util.go
10
p2p/util.go
|
|
@ -18,6 +18,7 @@ package p2p
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/heap"
|
"container/heap"
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common/mclock"
|
"github.com/ethereum/go-ethereum/common/mclock"
|
||||||
)
|
)
|
||||||
|
|
@ -43,12 +44,9 @@ func (h *expHeap) add(item string, exp mclock.AbsTime) {
|
||||||
|
|
||||||
// contains checks whether an item is present.
|
// contains checks whether an item is present.
|
||||||
func (h expHeap) contains(item string) bool {
|
func (h expHeap) contains(item string) bool {
|
||||||
for _, v := range h {
|
return slices.ContainsFunc(h, func(e expItem) bool {
|
||||||
if v.item == item {
|
return e.item == item
|
||||||
return true
|
})
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// expire removes items with expiry time before 'now'.
|
// expire removes items with expiry time before 'now'.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue