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

@@ -2,7 +2,7 @@ package filer
import (
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"sort"
"golang.org/x/exp/slices"
)
func readResolvedChunks(chunks []*filer_pb.FileChunk) (visibles []VisibleInterval) {
@@ -22,17 +22,14 @@ func readResolvedChunks(chunks []*filer_pb.FileChunk) (visibles []VisibleInterva
isStart: false,
})
}
sort.Slice(points, func(i, j int) bool {
if points[i].x != points[j].x {
return points[i].x < points[j].x
slices.SortFunc(points, func(a, b *Point) bool {
if a.x != b.x {
return a.x < b.x
}
if points[i].ts != points[j].ts {
return points[i].ts < points[j].ts
if a.ts != b.ts {
return a.ts < b.ts
}
if !points[i].isStart {
return true
}
return false
return !a.isStart
})
var prevX int64