refactor(cmd): migrate sort.Slice to slices.SortFunc (bd-u2sc.2)
Modernize sorting code to use Go 1.21+ slices package: - Replace sort.Slice with slices.SortFunc across 16 files - Use cmp.Compare for orderable types (strings, ints) - Use time.Time.Compare for time comparisons - Use cmp.Or for multi-field sorting - Use slices.SortStableFunc where stability matters Benefits: cleaner 3-way comparison, slightly better performance, modern idiomatic Go. Part of GH#692 refactoring epic. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"sort"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -247,11 +248,11 @@ func repairPrefixes(ctx context.Context, st storage.Storage, actorName string, t
|
||||
}
|
||||
|
||||
// Sort incorrect issues: first by prefix lexicographically, then by number
|
||||
sort.Slice(incorrectIssues, func(i, j int) bool {
|
||||
if incorrectIssues[i].prefix != incorrectIssues[j].prefix {
|
||||
return incorrectIssues[i].prefix < incorrectIssues[j].prefix
|
||||
}
|
||||
return incorrectIssues[i].number < incorrectIssues[j].number
|
||||
slices.SortFunc(incorrectIssues, func(a, b issueSort) int {
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.prefix, b.prefix),
|
||||
cmp.Compare(a.number, b.number),
|
||||
)
|
||||
})
|
||||
|
||||
// Get a database connection for ID generation
|
||||
|
||||
Reference in New Issue
Block a user