mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-19 01:49:56 +08:00
enhancement: replace sort.Slice with slices.SortFunc to reduce reflection
This commit is contained in:
@@ -9,9 +9,9 @@ import (
|
||||
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
|
||||
"github.com/chrislusf/seaweedfs/weed/storage/needle_map"
|
||||
"golang.org/x/exp/slices"
|
||||
"io"
|
||||
"math"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -70,8 +70,8 @@ func (c *commandVolumeCheckDisk) Do(args []string, commandEnv *CommandEnv, write
|
||||
}
|
||||
|
||||
for _, replicas := range volumeReplicas {
|
||||
sort.Slice(replicas, func(i, j int) bool {
|
||||
return fileCount(replicas[i]) > fileCount(replicas[j])
|
||||
slices.SortFunc(replicas, func(a, b *VolumeReplica) bool {
|
||||
return fileCount(a) > fileCount(b)
|
||||
})
|
||||
for len(replicas) >= 2 {
|
||||
a, b := replicas[0], replicas[1]
|
||||
|
Reference in New Issue
Block a user