aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_ec_common.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/command_ec_common.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/command_ec_common.go')
-rw-r--r--weed/shell/command_ec_common.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/weed/shell/command_ec_common.go b/weed/shell/command_ec_common.go
index b3bd0ce5d..27b650731 100644
--- a/weed/shell/command_ec_common.go
+++ b/weed/shell/command_ec_common.go
@@ -3,18 +3,17 @@ package shell
import (
"context"
"fmt"
- "github.com/chrislusf/seaweedfs/weed/pb"
- "github.com/chrislusf/seaweedfs/weed/storage/types"
- "math"
- "sort"
-
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/operation"
+ "github.com/chrislusf/seaweedfs/weed/pb"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
"github.com/chrislusf/seaweedfs/weed/storage/erasure_coding"
"github.com/chrislusf/seaweedfs/weed/storage/needle"
+ "github.com/chrislusf/seaweedfs/weed/storage/types"
+ "golang.org/x/exp/slices"
"google.golang.org/grpc"
+ "math"
)
func moveMountedShardToEcNode(commandEnv *CommandEnv, existingLocation *EcNode, collection string, vid needle.VolumeId, shardId erasure_coding.ShardId, destinationEcNode *EcNode, applyBalancing bool) (err error) {
@@ -116,14 +115,14 @@ func eachDataNode(topo *master_pb.TopologyInfo, fn func(dc string, rack RackId,
}
func sortEcNodesByFreeslotsDecending(ecNodes []*EcNode) {
- sort.Slice(ecNodes, func(i, j int) bool {
- return ecNodes[i].freeEcSlot > ecNodes[j].freeEcSlot
+ slices.SortFunc(ecNodes, func(a, b *EcNode) bool {
+ return a.freeEcSlot > b.freeEcSlot
})
}
func sortEcNodesByFreeslotsAscending(ecNodes []*EcNode) {
- sort.Slice(ecNodes, func(i, j int) bool {
- return ecNodes[i].freeEcSlot < ecNodes[j].freeEcSlot
+ slices.SortFunc(ecNodes, func(a, b *EcNode) bool {
+ return a.freeEcSlot < b.freeEcSlot
})
}