From 8eda54eaf86985c53d321f8e03bf3d2b51891d7d Mon Sep 17 00:00:00 2001 From: xixishidibei Date: Wed, 2 Apr 2025 20:44:21 +0800 Subject: [PATCH] refactor: use slices.Equal to simplify code Signed-off-by: xixishidibei --- chain/types/tipset.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/chain/types/tipset.go b/chain/types/tipset.go index 7ef0c2678c6..ff9c7c872c3 100644 --- a/chain/types/tipset.go +++ b/chain/types/tipset.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "io" + "slices" "sort" "github.com/ipfs/go-cid" @@ -172,17 +173,7 @@ func (ts *TipSet) Equals(ots *TipSet) bool { return false } - if len(ts.cids) != len(ots.cids) { - return false - } - - for i, cid := range ts.cids { - if cid != ots.cids[i] { - return false - } - } - - return true + return slices.Equal(ts.cids, ots.cids) } func (t *Ticket) Less(o *Ticket) bool {