Skip to content

Commit 28699c9

Browse files
authored
refactor: use slices.Sort where appropriate (#1965)
Signed-off-by: hongmengning <hongmengning@outlook.com>
1 parent f8a1b9e commit 28699c9

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

x/dymns/utils/map.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package utils
22

3-
import "sort"
3+
import "slices"
44

55
// GetSortedStringKeys returns the sorted keys of a map[string]V.
66
func GetSortedStringKeys[V any](m map[string]V) []string {
77
keys := make([]string, 0, len(m))
88
for k := range m {
99
keys = append(keys, k)
1010
}
11-
sort.Slice(keys, func(i, j int) bool {
12-
return keys[i] < keys[j]
13-
})
11+
slices.Sort(keys)
1412
return keys
1513
}

x/lockup/keeper/lock.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package keeper
22

33
import (
44
"fmt"
5+
"slices"
56
"sort"
67
"time"
78

@@ -491,7 +492,7 @@ func (k Keeper) InitializeAllLocks(ctx sdk.Context, locks []types.PeriodLock) er
491492
for duration := range curDurationMap {
492493
durations = append(durations, duration)
493494
}
494-
sort.Slice(durations, func(i, j int) bool { return durations[i] < durations[j] })
495+
slices.Sort(durations)
495496
// now that we have a sorted list of durations for this denom,
496497
// add them all to accumulation store
497498
msg := fmt.Sprintf("Setting accumulation entries for locks for %s, there are %d distinct durations",

0 commit comments

Comments
 (0)