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/filechunks2_test.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/filechunks2_test.go')
| -rw-r--r-- | weed/filer/filechunks2_test.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/weed/filer/filechunks2_test.go b/weed/filer/filechunks2_test.go index 9f9566d9b..39dec87c9 100644 --- a/weed/filer/filechunks2_test.go +++ b/weed/filer/filechunks2_test.go @@ -1,7 +1,7 @@ package filer import ( - "sort" + "golang.org/x/exp/slices" "testing" "github.com/chrislusf/seaweedfs/weed/glog" @@ -34,11 +34,11 @@ func TestCompactFileChunksRealCase(t *testing.T) { } func printChunks(name string, chunks []*filer_pb.FileChunk) { - sort.Slice(chunks, func(i, j int) bool { - if chunks[i].Offset == chunks[j].Offset { - return chunks[i].Mtime < chunks[j].Mtime + slices.SortFunc(chunks, func(a, b *filer_pb.FileChunk) bool { + if a.Offset == b.Offset { + return a.Mtime < b.Mtime } - return chunks[i].Offset < chunks[j].Offset + return a.Offset < b.Offset }) for _, chunk := range chunks { glog.V(0).Infof("%s chunk %s [%10d,%10d)", name, chunk.GetFileIdString(), chunk.Offset, chunk.Offset+int64(chunk.Size)) |
