From 0e11cbe9dd6e7c84c86ee830c5e9774e90277fab Mon Sep 17 00:00:00 2001 From: Ekaterina Lebedeva Date: Thu, 12 Dec 2024 17:46:30 +0300 Subject: [PATCH] [#1453] container: Replace `sort.Slice` with `slices.SortFunc` * Replaced `sort.Slice` with `slices.SortFunc` in `ListContainersRes.SortedIDList()` as it is a bit faster, according to 15102e6dfd. Signed-off-by: Ekaterina Lebedeva --- cmd/frostfs-cli/internal/client/client.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmd/frostfs-cli/internal/client/client.go b/cmd/frostfs-cli/internal/client/client.go index 948d61f36..851cf5ccc 100644 --- a/cmd/frostfs-cli/internal/client/client.go +++ b/cmd/frostfs-cli/internal/client/client.go @@ -9,7 +9,6 @@ import ( "io" "os" "slices" - "sort" "strings" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/accounting" @@ -78,9 +77,8 @@ func ListContainers(ctx context.Context, prm ListContainersPrm) (res ListContain // SortedIDList returns sorted list of identifiers of user's containers. func (x ListContainersRes) SortedIDList() []cid.ID { list := x.cliRes.Containers() - sort.Slice(list, func(i, j int) bool { - lhs, rhs := list[i].EncodeToString(), list[j].EncodeToString() - return strings.Compare(lhs, rhs) < 0 + slices.SortFunc(list, func(lhs, rhs cid.ID) int { + return strings.Compare(lhs.EncodeToString(), rhs.EncodeToString()) }) return list }