From 70bede930f0f0cf41e87b8d6f83fdae5e7f83984 Mon Sep 17 00:00:00 2001 From: Owen Diehl Date: Wed, 14 Feb 2024 16:01:42 -0800 Subject: [PATCH] remove unnecessary token sorting Signed-off-by: Owen Diehl --- pkg/bloomutils/ring.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pkg/bloomutils/ring.go b/pkg/bloomutils/ring.go index d05b91d644df2..20bb446ba15d3 100644 --- a/pkg/bloomutils/ring.go +++ b/pkg/bloomutils/ring.go @@ -45,16 +45,8 @@ func (i InstancesWithTokenRange) Contains(token uint32) bool { // token. func GetInstanceWithTokenRange(id string, instances []ring.InstanceDesc) (v1.FingerprintBounds, error) { - // Sorting the tokens of the instances would not be necessary if there is - // only a single token per instances, however, since we only assume one - // token, but don't enforce one token, we keep the sorting. - for _, inst := range instances { - sort.Slice(inst.Tokens, func(i, j int) bool { - return inst.Tokens[i] < inst.Tokens[j] - }) - } - - // Sort instances + // Sort instances -- they may not be sorted + // because they're usually accessed by looking up the tokens (which are sorted) sort.Slice(instances, func(i, j int) bool { return instances[i].Tokens[0] < instances[j].Tokens[0] })