refactor: use slices package for sorting (#10136)

Few more complicated usages of the sort packages are left.

### Purpose

Make progress towards replacing the sort package with slices package.
This commit is contained in:
Marcel Meyer
2025-05-26 20:37:49 +02:00
committed by GitHub
parent 905e5ec07f
commit 598915193a
18 changed files with 107 additions and 152 deletions
+2 -2
View File
@@ -117,8 +117,8 @@ func (m *tokenManager) saveLocked() {
for token, expiry := range m.tokens.Tokens {
tokens = append(tokens, tokenExpiry{token, expiry})
}
slices.SortFunc(tokens, func(i, j tokenExpiry) int {
return int(i.expiry - j.expiry)
slices.SortFunc(tokens, func(a, b tokenExpiry) int {
return int(a.expiry - b.expiry)
})
// Remove the oldest tokens.
for _, token := range tokens[:len(tokens)-m.maxItems] {