Pull request 1743: upd-sorting
Merge in DNS/adguard-home from upd-sorting to master Squashed commit of the following: commit 7bd21de65c50168d5ad83ff46e63f4cbca365d23 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Feb 21 10:57:17 2023 +0300 all: upd sorting, go-lint
This commit is contained in:
@@ -5,13 +5,13 @@ import (
|
||||
"encoding/binary"
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/AdguardTeam/golibs/errors"
|
||||
"github.com/AdguardTeam/golibs/log"
|
||||
"github.com/AdguardTeam/golibs/stringutil"
|
||||
"go.etcd.io/bbolt"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
// TODO(a.garipov): Rewrite all of this. Add proper error handling and
|
||||
@@ -180,8 +180,8 @@ func convertMapToSlice(m map[string]uint64, max int) (s []countPair) {
|
||||
s = append(s, countPair{Name: k, Count: v})
|
||||
}
|
||||
|
||||
sort.Slice(s, func(i, j int) bool {
|
||||
return s[j].Count < s[i].Count
|
||||
slices.SortFunc(s, func(a, b countPair) (sortsBefore bool) {
|
||||
return a.Count < b.Count
|
||||
})
|
||||
if max > len(s) {
|
||||
max = len(s)
|
||||
|
||||
Reference in New Issue
Block a user