mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-20 01:47:33 +00:00
all: use iterators over slice views more
This gets close to all of the remaining ones. Updates #12912 Change-Id: I9c672bbed2654a6c5cab31e0cbece6c107d8c6fa Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
00be1761b7
commit
4e0fc037e6
@@ -852,8 +852,7 @@ func (e *userspaceEngine) updateActivityMapsLocked(trackNodes []key.NodePublic,
|
||||
// hasOverlap checks if there is a IPPrefix which is common amongst the two
|
||||
// provided slices.
|
||||
func hasOverlap(aips, rips views.Slice[netip.Prefix]) bool {
|
||||
for i := range aips.Len() {
|
||||
aip := aips.At(i)
|
||||
for _, aip := range aips.All() {
|
||||
if views.SliceContains(rips, aip) {
|
||||
return true
|
||||
}
|
||||
@@ -1329,9 +1328,9 @@ func (e *userspaceEngine) mySelfIPMatchingFamily(dst netip.Addr) (src netip.Addr
|
||||
if addrs.Len() == 0 {
|
||||
return zero, errors.New("no self address in netmap")
|
||||
}
|
||||
for i := range addrs.Len() {
|
||||
if a := addrs.At(i); a.IsSingleIP() && a.Addr().BitLen() == dst.BitLen() {
|
||||
return a.Addr(), nil
|
||||
for _, p := range addrs.All() {
|
||||
if p.IsSingleIP() && p.Addr().BitLen() == dst.BitLen() {
|
||||
return p.Addr(), nil
|
||||
}
|
||||
}
|
||||
return zero, errors.New("no self address in netmap matching address family")
|
||||
|
Reference in New Issue
Block a user