From bf44f9c5336a7496aba9f4a8efff08a4671cfc40 Mon Sep 17 00:00:00 2001 From: tsinglua Date: Thu, 12 Mar 2026 10:55:23 +0800 Subject: [PATCH] refactor: replace sort.Slice with slices.Sort for natural ordering Signed-off-by: tsinglua --- utils/utils.go | 6 ++---- x/vm/keeper/params.go | 5 +---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index 57ec19be1..daa68ba0e 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -5,7 +5,7 @@ import ( "fmt" "math/big" "path/filepath" - "sort" + "slices" "strings" "github.com/ethereum/go-ethereum/common" @@ -195,9 +195,7 @@ func GetIBCDenomAddress(denom string) (common.Address, error) { // SortSlice sorts a slice of any ordered type. func SortSlice[T cmp.Ordered](slice []T) { - sort.Slice(slice, func(i, j int) bool { - return slice[i] < slice[j] - }) + slices.Sort(slice) } func Uint256FromBigInt(i *big.Int) (*uint256.Int, error) { diff --git a/x/vm/keeper/params.go b/x/vm/keeper/params.go index 833553d4f..7b7b39ff6 100644 --- a/x/vm/keeper/params.go +++ b/x/vm/keeper/params.go @@ -3,7 +3,6 @@ package keeper import ( "fmt" "slices" - "sort" "github.com/ethereum/go-ethereum/common" "go.opentelemetry.io/otel/attribute" @@ -104,9 +103,7 @@ func (k Keeper) EnableEIPs(ctx sdk.Context, eips ...int64) (err error) { evmParams := k.GetParams(ctx) evmParams.ExtraEIPs = append(evmParams.ExtraEIPs, eips...) - sort.Slice(evmParams.ExtraEIPs, func(i, j int) bool { - return evmParams.ExtraEIPs[i] < evmParams.ExtraEIPs[j] - }) + slices.Sort(evmParams.ExtraEIPs) return k.SetParams(ctx, evmParams) }