Skip to content

Commit b6432dc

Browse files
committed
remove unused routeSlice
1 parent 7756ff6 commit b6432dc

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

common.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,10 @@ func (rt rtInfo) IsMoreSpecThan(mostSpecificRt *rtInfo) bool {
6060
return mostSpecificRt.Priority >= rt.Priority
6161
}
6262

63-
// routeSlice implements sort.Interface to sort routes by Priority.
64-
type routeSlice []*rtInfo
65-
66-
func (r routeSlice) Len() int {
67-
return len(r)
68-
}
69-
func (r routeSlice) Less(i, j int) bool {
70-
return r[i].Priority < r[j].Priority
71-
}
72-
func (r routeSlice) Swap(i, j int) {
73-
r[i], r[j] = r[j], r[i]
74-
}
75-
7663
type router struct {
7764
ifaces map[int]net.Interface
7865
addrs map[int]ipAddrs
79-
v4, v6 routeSlice
66+
v4, v6 []*rtInfo
8067
}
8168

8269
func (r *router) String() string {
@@ -132,7 +119,7 @@ func (r *router) RouteWithSrc(input net.HardwareAddr, src, dst net.IP) (iface *n
132119
return
133120
}
134121

135-
func (r *router) route(routes routeSlice, input net.HardwareAddr, src, dst net.IP) (iface int, gateway, preferredSrc net.IP, err error) {
122+
func (r *router) route(routes []*rtInfo, input net.HardwareAddr, src, dst net.IP) (iface int, gateway, preferredSrc net.IP, err error) {
136123
var inputIndex uint32
137124
if input != nil {
138125
for i, iface := range r.ifaces {

netroute_plan9.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func New() (Router, error) {
5555
return rtr, nil
5656
}
5757

58-
func parseIPRoutes() (v4, v6 routeSlice, err error) {
58+
func parseIPRoutes() (v4, v6 []*rtInfo, err error) {
5959
buf, err := os.ReadFile(netdir + "/iproute")
6060
if err != nil {
6161
return nil, nil, err

netroute_stub.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func New() (Router, error) {
1414
rtr.ifaces[0] = net.Interface{}
1515
rtr.addrs = make(map[int]ipAddrs)
1616
rtr.addrs[0] = ipAddrs{}
17-
rtr.v4 = routeSlice{&rtInfo{}}
18-
rtr.v6 = routeSlice{&rtInfo{}}
17+
rtr.v4 = []*rtInfo{&rtInfo{}}
18+
rtr.v6 = []*rtInfo{&rtInfo{}}
1919
return rtr, nil
2020
}

0 commit comments

Comments
 (0)