From 3e8766da580166fbfd913b7ca21d5cc6bfcb21ba Mon Sep 17 00:00:00 2001 From: findfluctuate Date: Wed, 24 Dec 2025 11:26:49 +0800 Subject: [PATCH] refactor: replace sort.Slice with slices.Sort for natural ordering Signed-off-by: findfluctuate --- e2e/app/admin/test.go | 4 ++-- halo/registry/keeper/cache.go | 6 ++---- lib/netconf/netconf.go | 6 ++---- lib/netconf/network.go | 6 ++---- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/e2e/app/admin/test.go b/e2e/app/admin/test.go index 214a41ed9..e7fdddc2d 100644 --- a/e2e/app/admin/test.go +++ b/e2e/app/admin/test.go @@ -4,7 +4,7 @@ package admin import ( "context" "math/rand" - "sort" + "slices" "github.com/omni-network/omni/contracts/bindings" "github.com/omni-network/omni/e2e/app" @@ -398,7 +398,7 @@ func randBridgeSpec() BridgeSpec { } func sortUint64(ns []uint64) { - sort.Slice(ns, func(i, j int) bool { return ns[i] < ns[j] }) + slices.Sort(ns) } func randChain(chains []types.EVMChain) types.EVMChain { diff --git a/halo/registry/keeper/cache.go b/halo/registry/keeper/cache.go index b4eac31fe..b10d6d898 100644 --- a/halo/registry/keeper/cache.go +++ b/halo/registry/keeper/cache.go @@ -2,7 +2,7 @@ package keeper import ( "context" - "sort" + "slices" "sync" "github.com/omni-network/omni/halo/registry/types" @@ -72,9 +72,7 @@ func (k Keeper) ConfLevels(ctx context.Context) (map[uint64][]xchain.ConfLevel, confLevels = append(confLevels, confLevel) } - sort.Slice(confLevels, func(i, j int) bool { - return confLevels[i] < confLevels[j] - }) + slices.Sort(confLevels) resp[portal.GetChainId()] = confLevels } diff --git a/lib/netconf/netconf.go b/lib/netconf/netconf.go index 9d97f7b43..9814b559a 100644 --- a/lib/netconf/netconf.go +++ b/lib/netconf/netconf.go @@ -4,7 +4,7 @@ package netconf import ( "fmt" - "sort" + "slices" "time" "github.com/omni-network/omni/lib/errors" @@ -385,9 +385,7 @@ func (c Chain) ConfLevels() []xchain.ConfLevel { } // Sort for deterministic ordering. - sort.Slice(confs, func(i, j int) bool { - return confs[i] < confs[j] - }) + slices.Sort(confs) return confs } diff --git a/lib/netconf/network.go b/lib/netconf/network.go index e2e705194..ebd572dd4 100644 --- a/lib/netconf/network.go +++ b/lib/netconf/network.go @@ -1,7 +1,7 @@ package netconf import ( - "sort" + "slices" "github.com/omni-network/omni/lib/errors" ) @@ -90,9 +90,7 @@ func All() []ID { } } - sort.Slice(resp, func(i, j int) bool { - return resp[i] < resp[j] - }) + slices.Sort(resp) return resp }