diff options
| author | justin <leyou240@live.cn> | 2022-04-18 10:35:43 +0800 |
|---|---|---|
| committer | justin <leyou240@live.cn> | 2022-04-18 10:35:43 +0800 |
| commit | 3551ca2fcf423464afb2db4b5792c22ec94c2bfd (patch) | |
| tree | ee1f372e32fb03d93aeb0825ec0f068ef1fce161 /weed/filer/filechunks_read.go | |
| parent | c6ec5269f4b34d79ab8e13050623501b8befda32 (diff) | |
| download | seaweedfs-3551ca2fcf423464afb2db4b5792c22ec94c2bfd.tar.xz seaweedfs-3551ca2fcf423464afb2db4b5792c22ec94c2bfd.zip | |
enhancement: replace sort.Slice with slices.SortFunc to reduce reflection
Diffstat (limited to 'weed/filer/filechunks_read.go')
| -rw-r--r-- | weed/filer/filechunks_read.go | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/weed/filer/filechunks_read.go b/weed/filer/filechunks_read.go index 33ee6d138..1d0bd837a 100644 --- a/weed/filer/filechunks_read.go +++ b/weed/filer/filechunks_read.go @@ -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 |
