timeval: add UNLIKELY annotation
authorLennart Poettering <lennart@poettering.net>
Fri, 18 Sep 2009 02:11:02 +0000 (04:11 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 18 Sep 2009 02:14:38 +0000 (04:14 +0200)
src/pulse/timeval.c

index 1a0d3ce..87569cf 100644 (file)
@@ -83,7 +83,7 @@ pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) {
     pa_assert(b);
 
     /* Check which whan is the earlier time and swap the two arguments if required. */
-    if (pa_timeval_cmp(a, b) < 0) {
+    if (PA_UNLIKELY(pa_timeval_cmp(a, b) < 0)) {
         const struct timeval *c;
         c = a;
         a = b;
@@ -95,9 +95,9 @@ pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) {
 
     /* Calculate the microsecond difference */
     if (a->tv_usec > b->tv_usec)
-        r += ((pa_usec_t) a->tv_usec - (pa_usec_t) b->tv_usec);
+        r += (pa_usec_t) a->tv_usec - (pa_usec_t) b->tv_usec;
     else if (a->tv_usec < b->tv_usec)
-        r -= ((pa_usec_t) b->tv_usec - (pa_usec_t) a->tv_usec);
+        r -= (pa_usec_t) b->tv_usec - (pa_usec_t) a->tv_usec;
 
     return r;
 }