mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 13:18:53 +00:00
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:
@@ -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
|
||||
|
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user