lq: minor optimisation
authorFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 11 Apr 2016 12:45:12 +0000 (14:45 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 11 Apr 2016 12:59:16 +0000 (14:59 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
src/lq_plugin.c

index b7cc1a1..299e7f6 100644 (file)
@@ -318,16 +318,9 @@ get_tc_edge_entry_text(struct tc_edge_entry *entry, char separator, struct lqtex
 const char *
 get_linkcost_text(olsr_linkcost cost, bool route, struct lqtextbuffer *buffer)
 {
-  static const char *infinite = "INFINITE";
-
-  if (route) {
-    if (cost >= ROUTE_COST_BROKEN) {
-      return infinite;
-    }
-  } else {
-    if (cost >= LINK_COST_BROKEN) {
-      return infinite;
-    }
+  olsr_linkcost limit = route ? ROUTE_COST_BROKEN : LINK_COST_BROKEN;
+  if (cost >= limit) {
+    return "INFINITE";
   }
 
   snprintf(buffer->buf, sizeof(buffer->buf), "%.3f", active_lq_handler->get_cost_scaled(cost));