aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/shell_liner.go
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2022-04-17 20:59:31 -0700
committerGitHub <noreply@github.com>2022-04-17 20:59:31 -0700
commit61af76c3bb03bf40e3444c50724c8d5a1a2eafb4 (patch)
treee7bbc83368c814afa3d6c81c808738f91e32afd4 /weed/shell/shell_liner.go
parentb597baf488fa4449d41ac2b78d421751f65f909e (diff)
parent89eb87c1d16640030927af242b34eba47a149427 (diff)
downloadseaweedfs-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/shell/shell_liner.go')
-rw-r--r--weed/shell/shell_liner.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/weed/shell/shell_liner.go b/weed/shell/shell_liner.go
index 90ce2dbb4..94a68f5bc 100644
--- a/weed/shell/shell_liner.go
+++ b/weed/shell/shell_liner.go
@@ -8,12 +8,12 @@ import (
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
"github.com/chrislusf/seaweedfs/weed/util/grace"
+ "golang.org/x/exp/slices"
"io"
"math/rand"
"os"
"path"
"regexp"
- "sort"
"strings"
"github.com/peterh/liner"
@@ -25,11 +25,9 @@ var (
)
func RunShell(options ShellOptions) {
-
- sort.Slice(Commands, func(i, j int) bool {
- return strings.Compare(Commands[i].Name(), Commands[j].Name()) < 0
+ slices.SortFunc(Commands, func(a, b command) bool {
+ return strings.Compare(a.Name(), b.Name()) < 0
})
-
line = liner.NewLiner()
defer line.Close()
grace.OnInterrupt(func() {