瀏覽代碼

pkt_sched: sch_htb: Optimize htb_find_next_upper()

htb_id_find_next_upper() is usually called to find a class with next
id after some previously removed class, so let's move a check for
equality to the end: it's the least likely here.

Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Jarek Poplawski 16 年之前
父節點
當前提交
1b5c0077e1
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      net/sched/sch_htb.c

+ 3 - 3
net/sched/sch_htb.c

@@ -698,14 +698,14 @@ static struct rb_node *htb_id_find_next_upper(int prio, struct rb_node *n,
 	while (n) {
 	while (n) {
 		struct htb_class *cl =
 		struct htb_class *cl =
 		    rb_entry(n, struct htb_class, node[prio]);
 		    rb_entry(n, struct htb_class, node[prio]);
-		if (id == cl->common.classid)
-			return n;
 
 
 		if (id > cl->common.classid) {
 		if (id > cl->common.classid) {
 			n = n->rb_right;
 			n = n->rb_right;
-		} else {
+		} else if (id < cl->common.classid) {
 			r = n;
 			r = n;
 			n = n->rb_left;
 			n = n->rb_left;
+		} else {
+			return n;
 		}
 		}
 	}
 	}
 	return r;
 	return r;