From d38bf643ed1ad9a9a41d48ee0f1676b29e70a834 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 5 Mar 2025 12:40:18 -0500 Subject: [PATCH] refactor: use slices.Contains to simplify code (backport #23894) (#23900) Co-authored-by: huochexizhan --- store/types/store.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/store/types/store.go b/store/types/store.go index 8980179950..c2ee3b8e7f 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -3,6 +3,7 @@ package types import ( "fmt" "io" + "slices" "github.com/cometbft/cometbft/proto/tendermint/crypto" dbm "github.com/cosmos/cosmos-db" @@ -85,12 +86,7 @@ func (s *StoreUpgrades) IsAdded(key string) bool { if s == nil { return false } - for _, added := range s.Added { - if key == added { - return true - } - } - return false + return slices.Contains(s.Added, key) } // IsDeleted returns true if the given key should be deleted @@ -98,12 +94,7 @@ func (s *StoreUpgrades) IsDeleted(key string) bool { if s == nil { return false } - for _, d := range s.Deleted { - if d == key { - return true - } - } - return false + return slices.Contains(s.Deleted, key) } // RenamedFrom returns the oldKey if it was renamed