mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
simplify sort.Sort by using sort.Slice (#17066)
This commit is contained in:
@@ -94,15 +94,6 @@ func (er erasureObjects) defaultWQuorum() int {
|
||||
return dataCount
|
||||
}
|
||||
|
||||
// byDiskTotal is a collection satisfying sort.Interface.
|
||||
type byDiskTotal []madmin.Disk
|
||||
|
||||
func (d byDiskTotal) Len() int { return len(d) }
|
||||
func (d byDiskTotal) Swap(i, j int) { d[i], d[j] = d[j], d[i] }
|
||||
func (d byDiskTotal) Less(i, j int) bool {
|
||||
return d[i].TotalSpace < d[j].TotalSpace
|
||||
}
|
||||
|
||||
func diskErrToDriveState(err error) (state string) {
|
||||
switch {
|
||||
case errors.Is(err, errDiskNotFound) || errors.Is(err, context.DeadlineExceeded):
|
||||
@@ -245,7 +236,9 @@ func getStorageInfo(disks []StorageAPI, endpoints []Endpoint) StorageInfo {
|
||||
disksInfo := getDisksInfo(disks, endpoints)
|
||||
|
||||
// Sort so that the first element is the smallest.
|
||||
sort.Sort(byDiskTotal(disksInfo))
|
||||
sort.Slice(disksInfo, func(i, j int) bool {
|
||||
return disksInfo[i].TotalSpace < disksInfo[j].TotalSpace
|
||||
})
|
||||
|
||||
storageInfo := StorageInfo{
|
||||
Disks: disksInfo,
|
||||
|
||||
Reference in New Issue
Block a user