From: Willy Tarreau Date: Thu, 4 Sep 2008 07:00:24 +0000 (+0200) Subject: [OPTIM] add compiler hints in tick_is_expired() X-Git-Tag: v1.3.16-rc1~152 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=534c5a222496b1b6551f26e8205eff83629f974a;p=thirdparty%2Fhaproxy.git [OPTIM] add compiler hints in tick_is_expired() adding those two unlikely() reduces the number of branches taken in the common path and the size of the code. --- diff --git a/include/common/ticks.h b/include/common/ticks.h index 462dccaaea..0b3e102e13 100644 --- a/include/common/ticks.h +++ b/include/common/ticks.h @@ -82,9 +82,11 @@ static inline int tick_add_ifset(int now, int timeout) /* return 1 if timer is expired at date , 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 */