Skip to content

Commit 9186ebd

Browse files
authored
cleanup: use slices.Equal to simplify code (#8472)
1 parent 55e8b90 commit 9186ebd

File tree

4 files changed

+2
-106
lines changed

4 files changed

+2
-106
lines changed

xds/internal/balancer/clusterimpl/clusterimpl.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"context"
2828
"encoding/json"
2929
"fmt"
30+
"slices"
3031
"sync"
3132
"sync/atomic"
3233
"time"
@@ -128,7 +129,7 @@ type clusterImplBalancer struct {
128129
// indicating if a new picker needs to be generated.
129130
func (b *clusterImplBalancer) handleDropAndRequestCountLocked(newConfig *LBConfig) bool {
130131
var updatePicker bool
131-
if !equalDropCategories(b.dropCategories, newConfig.DropCategories) {
132+
if !slices.Equal(b.dropCategories, newConfig.DropCategories) {
132133
b.dropCategories = newConfig.DropCategories
133134
b.drops = make([]*dropper, 0, len(newConfig.DropCategories))
134135
for _, c := range newConfig.DropCategories {

xds/internal/balancer/clusterimpl/config.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,3 @@ func parseConfig(c json.RawMessage) (*LBConfig, error) {
5555
}
5656
return &cfg, nil
5757
}
58-
59-
func equalDropCategories(a, b []DropConfig) bool {
60-
if len(a) != len(b) {
61-
return false
62-
}
63-
for i := range a {
64-
if a[i] != b[i] {
65-
return false
66-
}
67-
}
68-
return true
69-
}

xds/internal/balancer/priority/utils.go

Lines changed: 0 additions & 31 deletions
This file was deleted.

xds/internal/balancer/priority/utils_test.go

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)