Skip to contentSkip to conversation

pkt_sched: sch_htb: Optimize htb_find_next_upper()

PATCH Applied Jarek Poplawski 1 participant 1 message Dec 9, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 5/6 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.

---
 net/sched/sch_htb.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
net/sched/sch_htb.c +3 -3
index 2e0a74c..f44a4be 100644
@@ -702,14 +702,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;
Signature · 1 line
1.5.6.5