refactor: use slices.Contains to simplify code (backport #23894) (#23900)

Co-authored-by: huochexizhan <huochexizhan@outlook.com>
This commit is contained in:
mergify[bot]
2025-03-05 12:40:18 -05:00
committed by GitHub
co-authored by huochexizhan
parent e8579020cb
commit d38bf643ed
+3 -12
View File
@@ -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