Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 77af49c

Browse files
authoredMar 5, 2025··
refactor: use slices.Contains to simplify code (#23894)
Signed-off-by: huochexizhan <[email protected]>
1 parent 5411e73 commit 77af49c

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed
 

‎store/types/store.go

+3-12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package types
33
import (
44
"fmt"
55
"io"
6+
"slices"
67

78
crypto "github.com/cometbft/cometbft/api/cometbft/crypto/v1"
89

@@ -96,25 +97,15 @@ func (s *StoreUpgrades) IsAdded(key string) bool {
9697
if s == nil {
9798
return false
9899
}
99-
for _, added := range s.Added {
100-
if key == added {
101-
return true
102-
}
103-
}
104-
return false
100+
return slices.Contains(s.Added, key)
105101
}
106102

107103
// IsDeleted returns true if the given key should be deleted
108104
func (s *StoreUpgrades) IsDeleted(key string) bool {
109105
if s == nil {
110106
return false
111107
}
112-
for _, d := range s.Deleted {
113-
if d == key {
114-
return true
115-
}
116-
}
117-
return false
108+
return slices.Contains(s.Deleted, key)
118109
}
119110

120111
// RenamedFrom returns the oldKey if it was renamed

0 commit comments

Comments
 (0)
Please sign in to comment.