pkt_sched: sch_htb: Optimize htb_find_next_upper()
authorJarek Poplawski <jarkao2@gmail.com>
Wed, 10 Dec 2008 06:34:40 +0000 (22:34 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 10 Dec 2008 06:34:40 +0000 (22:34 -0800)
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>
net/sched/sch_htb.c

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