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/command/master.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/command/master.go')
| -rw-r--r-- | weed/command/master.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/weed/command/master.go b/weed/command/master.go index 37cfaf252..9587df055 100644 --- a/weed/command/master.go +++ b/weed/command/master.go @@ -1,9 +1,9 @@ package command import ( + "golang.org/x/exp/slices" "net/http" "os" - "sort" "strings" "time" @@ -274,8 +274,8 @@ func checkPeers(masterIp string, masterPort int, masterGrpcPort int, peers strin } func isTheFirstOne(self pb.ServerAddress, peers []pb.ServerAddress) bool { - sort.Slice(peers, func(i, j int) bool { - return strings.Compare(string(peers[i]), string(peers[j])) < 0 + slices.SortFunc(peers, func(a, b pb.ServerAddress) bool { + return strings.Compare(string(a), string(b)) < 0 }) if len(peers) <= 0 { return true |
