]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[OPTIM] add compiler hints in tick_is_expired()
authorWilly Tarreau <w@1wt.eu>
Thu, 4 Sep 2008 07:00:24 +0000 (09:00 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 2 Nov 2008 09:19:09 +0000 (10:19 +0100)
adding those two unlikely() reduces the number of branches taken in
the common path and the size of the code.

include/common/ticks.h

index 462dccaaeac0751f2658464406353dbf7c002cca..0b3e102e13fb05bc453203d3e7a4aae302549d3a 100644 (file)
@@ -82,9 +82,11 @@ static inline int tick_add_ifset(int now, int timeout)
 /* return 1 if timer <timer> is expired at date <now>, otherwise zero */
 static inline int tick_is_expired(int timer, int now)
 {
-       if (!tick_isset(timer))
+       if (unlikely(!tick_isset(timer)))
                return 0;
-       return (timer - now) <= 0;
+       if (unlikely((timer - now) <= 0))
+               return 1;
+       return 0;
 }
 
 /* return the first one of the two timers, both of which may be infinite */