[pulseaudio-discuss] [PATCH RFCv3 28/51] rtpoll: Annotate branches with LIKELY

Peter Meerwald pmeerw at pmeerw.net
Tue Nov 4 15:26:23 PST 2014


From: Peter Meerwald <p.meerwald at bct-electronic.com>

Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
---
 src/pulsecore/rtpoll.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/src/pulsecore/rtpoll.c b/src/pulsecore/rtpoll.c
index 5f3ca8b..1265993 100644
--- a/src/pulsecore/rtpoll.c
+++ b/src/pulsecore/rtpoll.c
@@ -196,7 +196,7 @@ static void reset_all_revents(pa_rtpoll *p) {
 
     for (i = p->items; i; i = i->next) {
 
-        if (i->dead)
+        if (PA_UNLIKELY(i->dead))
             continue;
 
         reset_revents(i);
@@ -222,20 +222,20 @@ int pa_rtpoll_run(pa_rtpoll *p) {
     for (i = p->items; i && i->priority < PA_RTPOLL_NEVER; i = i->next) {
         int k;
 
-        if (i->dead)
+        if (PA_UNLIKELY(i->dead))
             continue;
 
         if (!i->work_cb)
             continue;
 
-        if (p->quit) {
+        if (PA_UNLIKELY(p->quit)) {
 #ifdef DEBUG_TIMING
             pa_log("rtpoll finish");
 #endif
             goto finish;
         }
 
-        if ((k = i->work_cb(i)) != 0) {
+        if (PA_UNLIKELY((k = i->work_cb(i)) != 0)) {
             if (k < 0)
                 r = k;
 #ifdef DEBUG_TIMING
@@ -249,25 +249,23 @@ int pa_rtpoll_run(pa_rtpoll *p) {
     for (i = p->items; i && i->priority < PA_RTPOLL_NEVER; i = i->next) {
         int k = 0;
 
-        if (i->dead)
+        if (PA_UNLIKELY(i->dead))
             continue;
 
         if (!i->before_cb)
             continue;
 
-        if (p->quit || (k = i->before_cb(i)) != 0) {
+        if (PA_UNLIKELY(p->quit || (k = i->before_cb(i)) != 0)) {
 
             /* Hmm, this one doesn't let us enter the poll, so rewind everything */
 
             for (i = i->prev; i; i = i->prev) {
 
-                if (i->dead)
+                if (PA_UNLIKELY(i->dead))
                     continue;
 
-                if (!i->after_cb)
-                    continue;
-
-                i->after_cb(i);
+                if (i->after_cb)
+                    i->after_cb(i);
             }
 
             if (k < 0)
@@ -285,7 +283,7 @@ int pa_rtpoll_run(pa_rtpoll *p) {
     pa_zero(timeout);
 
     /* Calculate timeout */
-    if (!p->quit && p->timer_enabled) {
+    if (PA_LIKELY(!p->quit && p->timer_enabled)) {
         struct timeval now;
         pa_rtclock_get(&now);
 
@@ -333,7 +331,7 @@ int pa_rtpoll_run(pa_rtpoll *p) {
     }
 #endif
 
-    if (r < 0) {
+    if (PA_UNLIKELY(r < 0)) {
         if (errno == EAGAIN || errno == EINTR)
             r = 0;
         else
@@ -345,13 +343,11 @@ int pa_rtpoll_run(pa_rtpoll *p) {
     /* Let's tell everyone that we left the sleep */
     for (i = p->items; i && i->priority < PA_RTPOLL_NEVER; i = i->next) {
 
-        if (i->dead)
-            continue;
-
-        if (!i->after_cb)
+        if (PA_UNLIKELY(i->dead))
             continue;
 
-        i->after_cb(i);
+        if (i->after_cb)
+            i->after_cb(i);
     }
 
 finish:
@@ -366,7 +362,7 @@ finish:
         for (i = p->items; i; i = n) {
             n = i->next;
 
-            if (i->dead)
+            if (PA_UNLIKELY(i->dead))
                 rtpoll_item_destroy(i);
         }
     }
-- 
1.9.1



More information about the pulseaudio-discuss mailing list