Skip to content

Commit 1b5c007

Browse files
Jarek Poplawskidavem330
authored andcommitted
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>
1 parent dbb7a95 commit 1b5c007

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/sched/sch_htb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,14 +698,14 @@ static struct rb_node *htb_id_find_next_upper(int prio, struct rb_node *n,
698698
while (n) {
699699
struct htb_class *cl =
700700
rb_entry(n, struct htb_class, node[prio]);
701-
if (id == cl->common.classid)
702-
return n;
703701

704702
if (id > cl->common.classid) {
705703
n = n->rb_right;
706-
} else {
704+
} else if (id < cl->common.classid) {
707705
r = n;
708706
n = n->rb_left;
707+
} else {
708+
return n;
709709
}
710710
}
711711
return r;

0 commit comments

Comments
 (0)