From 16bf47444dfbefda4705a24585dc5b6c2953e665 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 5 Mar 2019 20:40:14 +0100 Subject: ifaceconfig: more compact less function Signed-off-by: Jason A. Donenfeld --- service/ifaceconfig.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'service/ifaceconfig.go') diff --git a/service/ifaceconfig.go b/service/ifaceconfig.go index b2f93b70..1bd5f690 100644 --- a/service/ifaceconfig.go +++ b/service/ifaceconfig.go @@ -206,19 +206,10 @@ func configureInterface(conf *conf.Config, guid *windows.GUID) error { deduplicatedRoutes := make([]*winipcfg.RouteData, routeCount) routeCount = 0 sort.Slice(routes, func(i, j int) bool { - if routes[i].Metric < routes[j].Metric { - return true - } - if bytes.Compare(routes[i].NextHop, routes[j].NextHop) == -1 { - return true - } - if bytes.Compare(routes[i].Destination.IP, routes[j].Destination.IP) == -1 { - return true - } - if bytes.Compare(routes[i].Destination.Mask, routes[j].Destination.Mask) == -1 { - return true - } - return false + return routes[i].Metric < routes[j].Metric || + bytes.Compare(routes[i].NextHop, routes[j].NextHop) == -1 || + bytes.Compare(routes[i].Destination.IP, routes[j].Destination.IP) == -1 || + bytes.Compare(routes[i].Destination.Mask, routes[j].Destination.Mask) == -1 }) for i := 0; i < len(routes); i++ { if i > 0 && routes[i].Metric == routes[i-1].Metric && -- cgit v1.2.3-59-g8ed1b