mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-19 10:48:03 +08:00
enhancement: replace sort.Slice with slices.SortFunc to reduce reflection
This commit is contained in:
@@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||
"github.com/chrislusf/seaweedfs/weed/storage/volume_info"
|
||||
"golang.org/x/exp/slices"
|
||||
"math"
|
||||
"os"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -82,9 +82,8 @@ func (ev *EcVolume) AddEcVolumeShard(ecVolumeShard *EcVolumeShard) bool {
|
||||
}
|
||||
}
|
||||
ev.Shards = append(ev.Shards, ecVolumeShard)
|
||||
sort.Slice(ev.Shards, func(i, j int) bool {
|
||||
return ev.Shards[i].VolumeId < ev.Shards[j].VolumeId ||
|
||||
ev.Shards[i].VolumeId == ev.Shards[j].VolumeId && ev.Shards[i].ShardId < ev.Shards[j].ShardId
|
||||
slices.SortFunc(ev.Shards, func(a, b *EcVolumeShard) bool {
|
||||
return a.VolumeId < b.VolumeId || a.VolumeId == b.VolumeId && a.ShardId < b.ShardId
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
Reference in New Issue
Block a user