diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2022-04-17 20:59:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-17 20:59:31 -0700 |
| commit | 61af76c3bb03bf40e3444c50724c8d5a1a2eafb4 (patch) | |
| tree | e7bbc83368c814afa3d6c81c808738f91e32afd4 /weed/filer/filechunks_read.go | |
| parent | b597baf488fa4449d41ac2b78d421751f65f909e (diff) | |
| parent | 89eb87c1d16640030927af242b34eba47a149427 (diff) | |
| download | seaweedfs-61af76c3bb03bf40e3444c50724c8d5a1a2eafb4.tar.xz seaweedfs-61af76c3bb03bf40e3444c50724c8d5a1a2eafb4.zip | |
Merge pull request #2929 from leyou240/slices.SortFunc
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 |
