From 63280ed437b2f5734bbfcd380e1c137d2928b083 Mon Sep 17 00:00:00 2001 From: one230six <723682061@qq.com> Date: Thu, 12 Jun 2025 11:23:19 +0800 Subject: [PATCH] refactor: use slices.Contains to simplify code Signed-off-by: one230six <723682061@qq.com> --- .../consensus/model/externalapi/blocklevelparents.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/domain/consensus/model/externalapi/blocklevelparents.go b/domain/consensus/model/externalapi/blocklevelparents.go index a4768e49b..0e34cbe67 100644 --- a/domain/consensus/model/externalapi/blocklevelparents.go +++ b/domain/consensus/model/externalapi/blocklevelparents.go @@ -1,5 +1,7 @@ package externalapi +import "slices" + // BlockLevelParents represent the parents within a single super-block level // See https://github.com/kaspanet/research/issues/3 for further details type BlockLevelParents []*DomainHash @@ -10,13 +12,7 @@ func (sl BlockLevelParents) Equal(other BlockLevelParents) bool { return false } for _, thisHash := range sl { - found := false - for _, otherHash := range other { - if thisHash.Equal(otherHash) { - found = true - break - } - } + found := slices.ContainsFunc(other, thisHash.Equal) if !found { return false }