From db307d35e11a11558cb4962dd62d91a348d1374e Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 8 Sep 2023 20:40:43 -0700 Subject: [PATCH] types/netmap: delete a copy of views.SliceEqual Updates #cleanup Change-Id: Ibdfa6c5dc9211f5c97c763ba323802a1c1d80c9e Signed-off-by: Brad Fitzpatrick --- types/netmap/netmap.go | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/types/netmap/netmap.go b/types/netmap/netmap.go index 41564ff2e..733352674 100644 --- a/types/netmap/netmap.go +++ b/types/netmap/netmap.go @@ -274,8 +274,8 @@ func nodeConciseEqual(a, b tailcfg.NodeView) bool { return a.Key() == b.Key() && a.DERP() == b.DERP() && a.DiscoKey() == b.DiscoKey() && - eqViewsIgnoreNil(a.AllowedIPs(), b.AllowedIPs()) && - eqViewsIgnoreNil(a.Endpoints(), b.Endpoints()) + views.SliceEqual(a.AllowedIPs(), b.AllowedIPs()) && + views.SliceEqual(a.Endpoints(), b.Endpoints()) } func (b *NetworkMap) ConciseDiffFrom(a *NetworkMap) string { @@ -341,21 +341,3 @@ const ( AllowSingleHosts WGConfigFlags = 1 << iota AllowSubnetRoutes ) - -// eqViewsIgnoreNil reports whether a and b have the same length and comparably -// equal values at each index. It's used for comparing views of slices and not -// caring about whether the slices are nil or not. -func eqViewsIgnoreNil[T comparable](a, b interface { - Len() int - At(int) T -}) bool { - if a.Len() != b.Len() { - return false - } - for i, n := 0, a.Len(); i < n; i++ { - if a.At(i) != b.At(i) { - return false - } - } - return true -}