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

Signed-off-by: huochexizhan <huochexizhan@outlook.com>
This commit is contained in:
huochexizhan 2025-03-05 17:48:20 +01:00 committed by GitHub
parent 5411e73bb8
commit 77af49c1d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@ package types
import (
"fmt"
"io"
"slices"
crypto "github.com/cometbft/cometbft/api/cometbft/crypto/v1"
@ -96,12 +97,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
@ -109,12 +105,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