Skip to content

Commit bd7891f

Browse files
refactor: replace sort.Slice with slices.Sort for natural ordering (#2768)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/ --> ## Overview There is a [new function](https://pkg.go.dev/slices#Sort) added in the go1.21 standard library, which can make the code more concise and easy to read. <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. Ex: Closes #<issue number> --> Signed-off-by: suranmiao <solsui@outlook.com> Co-authored-by: Marko <marko@baricevic.me>
1 parent 5d6f429 commit bd7891f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

tools/cache-analyzer/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"fmt"
88
"os"
99
"path/filepath"
10-
"sort"
10+
"slices"
1111
"strings"
1212

1313
"github.com/evstack/ev-node/types"
@@ -114,9 +114,7 @@ func analyzeEvents(events map[uint64]*DAHeightEvent, limit int) []eventEntry {
114114
for height := range events {
115115
heights = append(heights, height)
116116
}
117-
sort.Slice(heights, func(i, j int) bool {
118-
return heights[i] < heights[j]
119-
})
117+
slices.Sort(heights)
120118

121119
// Apply limit
122120
if limit > 0 && len(heights) > limit {

0 commit comments

Comments
 (0)