From 669103a33efc1ddedee847689e74c82441dc9916 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 10 Apr 2024 14:15:59 +0300 Subject: [PATCH] Reapply "[#972] Use slices.Sort* when useful" This reverts commit 3359349acbbfb0aa8e208c5286ff7bd6537df2be. Signed-off-by: Evgenii Stratonikov --- cmd/frostfs-cli/modules/control/shards_set_mode.go | 7 ++----- pkg/services/tree/getsubtree_test.go | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cmd/frostfs-cli/modules/control/shards_set_mode.go b/cmd/frostfs-cli/modules/control/shards_set_mode.go index 1c87b405b..e73f15178 100644 --- a/cmd/frostfs-cli/modules/control/shards_set_mode.go +++ b/cmd/frostfs-cli/modules/control/shards_set_mode.go @@ -3,7 +3,7 @@ package control import ( "bytes" "fmt" - "sort" + "slices" "strings" rawclient "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" @@ -177,9 +177,6 @@ func getShardIDListFromIDFlag(cmd *cobra.Command, withAllFlag bool) [][]byte { res = append(res, raw) } - sort.Slice(res, func(i, j int) bool { - return bytes.Compare(res[i], res[j]) < 0 - }) - + slices.SortFunc(res, bytes.Compare) return res } diff --git a/pkg/services/tree/getsubtree_test.go b/pkg/services/tree/getsubtree_test.go index 9a4223e30..305c2bac9 100644 --- a/pkg/services/tree/getsubtree_test.go +++ b/pkg/services/tree/getsubtree_test.go @@ -5,7 +5,7 @@ import ( "errors" "path" "path/filepath" - "sort" + "slices" "testing" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/pilorama" @@ -192,9 +192,7 @@ func testGetSubTreeOrderAsc(t *testing.T, p pilorama.ForestStorage) { require.True(t, found, "unknown node %d %v", i, acc.seen[i].GetBody().GetNodeId()) } - require.True(t, sort.SliceIsSorted(paths, func(i, j int) bool { - return paths[i] < paths[j] - })) + require.True(t, slices.IsSorted(paths)) }) t.Run("depth=1", func(t *testing.T) { acc := subTreeAcc{errIndex: -1}