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/shell/command_fs_meta_cat.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/shell/command_fs_meta_cat.go')
| -rw-r--r-- | weed/shell/command_fs_meta_cat.go | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/weed/shell/command_fs_meta_cat.go b/weed/shell/command_fs_meta_cat.go index a7de6d3ef..4616c072d 100644 --- a/weed/shell/command_fs_meta_cat.go +++ b/weed/shell/command_fs_meta_cat.go @@ -2,11 +2,10 @@ package shell import ( "fmt" + "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" + "golang.org/x/exp/slices" "io" - "sort" - - "github.com/golang/protobuf/jsonpb" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/util" @@ -55,14 +54,12 @@ func (c *commandFsMetaCat) Do(args []string, commandEnv *CommandEnv, writer io.W EmitDefaults: true, Indent: " ", } - - sort.Slice(respLookupEntry.Entry.Chunks, func(i, j int) bool { - if respLookupEntry.Entry.Chunks[i].Offset == respLookupEntry.Entry.Chunks[j].Offset { - return respLookupEntry.Entry.Chunks[i].Mtime < respLookupEntry.Entry.Chunks[j].Mtime + slices.SortFunc(respLookupEntry.Entry.Chunks, func(a, b *filer_pb.FileChunk) bool { + if a.Offset == b.Offset { + return a.Mtime < b.Mtime } - return respLookupEntry.Entry.Chunks[i].Offset < respLookupEntry.Entry.Chunks[j].Offset + return a.Offset < b.Offset }) - text, marshalErr := m.MarshalToString(respLookupEntry.Entry) if marshalErr != nil { return fmt.Errorf("marshal meta: %v", marshalErr) |
