enhancement: replace sort.Slice with slices.SortFunc to reduce reflection

This commit is contained in:
justin
2022-04-18 10:35:43 +08:00
parent c6ec5269f4
commit 3551ca2fcf
25 changed files with 117 additions and 139 deletions

View File

@@ -4,9 +4,9 @@ import (
"context"
"fmt"
"github.com/chrislusf/seaweedfs/weed/pb"
"golang.org/x/exp/slices"
"io"
"os"
"sort"
"sync"
"time"
@@ -389,8 +389,8 @@ func (s *Store) EcVolumes() (ecVolumes []*erasure_coding.EcVolume) {
}
location.ecVolumesLock.RUnlock()
}
sort.Slice(ecVolumes, func(i, j int) bool {
return ecVolumes[i].VolumeId > ecVolumes[j].VolumeId
slices.SortFunc(ecVolumes, func(a, b *erasure_coding.EcVolume) bool {
return a.VolumeId > b.VolumeId
})
return ecVolumes
}