util/cmpx: remove code that's in the stdlib now

The cmpx.Compare function (and associated interface) are now available
in the standard library as cmp.Compare. Remove our version of it and use
the version from the standard library.

Updates #cleanup

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: I4be3ac63d466c05eb7a0babb25cb0d41816fbd53
This commit is contained in:
Andrew Dunham
2023-12-18 17:43:01 -05:00
parent 945cf836ee
commit a661287c4b
8 changed files with 15 additions and 51 deletions

View File

@@ -5,6 +5,7 @@
package netmap
import (
"cmp"
"encoding/json"
"fmt"
"net/netip"
@@ -16,7 +17,6 @@ import (
"tailscale.com/tka"
"tailscale.com/types/key"
"tailscale.com/types/views"
"tailscale.com/util/cmpx"
"tailscale.com/wgengine/filter"
)
@@ -146,7 +146,7 @@ func (nm *NetworkMap) PeerIndexByNodeID(nodeID tailcfg.NodeID) int {
return -1
}
idx, ok := sort.Find(len(nm.Peers), func(i int) int {
return cmpx.Compare(nodeID, nm.Peers[i].ID())
return cmp.Compare(nodeID, nm.Peers[i].ID())
})
if !ok {
return -1

View File

@@ -4,6 +4,7 @@
package netmap
import (
"cmp"
"fmt"
"net/netip"
"reflect"
@@ -13,7 +14,6 @@ import (
"tailscale.com/tailcfg"
"tailscale.com/types/ptr"
"tailscale.com/util/cmpx"
)
// NodeMutation is the common interface for types that describe
@@ -139,7 +139,7 @@ func MutationsFromMapResponse(res *tailcfg.MapResponse, now time.Time) (ret []No
}
}
slices.SortStableFunc(ret, func(a, b NodeMutation) int {
return cmpx.Compare(a.NodeIDBeingMutated(), b.NodeIDBeingMutated())
return cmp.Compare(a.NodeIDBeingMutated(), b.NodeIDBeingMutated())
})
return ret, true
}