From ab0738fd7feb57788736d00d8a52219fdc5fdc83 Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Fri, 29 Mar 2024 17:29:44 +0800 Subject: [PATCH] p2p: using slices.ContainsFunc --- p2p/util.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/p2p/util.go b/p2p/util.go index 2c8f322a66..9ebf3cda96 100644 --- a/p2p/util.go +++ b/p2p/util.go @@ -18,6 +18,7 @@ package p2p import ( "container/heap" + "slices" "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. func (h expHeap) contains(item string) bool { - for _, v := range h { - if v.item == item { - return true - } - } - return false + return slices.ContainsFunc(h, func(e expItem) bool { + return e.item == item + }) } // expire removes items with expiry time before 'now'.