apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1064276 - /apr/apr/trunk/util-misc/apr_queue.c
Date Thu, 27 Jan 2011 19:44:50 GMT
Author: jim
Date: Thu Jan 27 19:44:50 2011
New Revision: 1064276

URL: http://svn.apache.org/viewvc?rev=1064276&view=rev
Log:
replace expensive % with faster (2-4x) functional equiv.

Modified:
    apr/apr/trunk/util-misc/apr_queue.c

Modified: apr/apr/trunk/util-misc/apr_queue.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/util-misc/apr_queue.c?rev=1064276&r1=1064275&r2=1064276&view=diff
==============================================================================
--- apr/apr/trunk/util-misc/apr_queue.c (original)
+++ apr/apr/trunk/util-misc/apr_queue.c Thu Jan 27 19:44:50 2011
@@ -185,7 +185,9 @@ APR_DECLARE(apr_status_t) apr_queue_push
     }
 
     queue->data[queue->in] = data;
-    queue->in = (queue->in + 1) % queue->bounds;
+    queue->in++;
+    if (queue->in >= queue->bounds)
+        queue->in -= queue->bounds;
     queue->nelts++;
 
     if (queue->empty_waiters) {
@@ -225,7 +227,9 @@ APR_DECLARE(apr_status_t) apr_queue_tryp
     }
     
     queue->data[queue->in] = data;
-    queue->in = (queue->in + 1) % queue->bounds;
+    queue->in++;
+    if (queue->in >= queue->bounds)
+        queue->in -= queue->bounds;
     queue->nelts++;
 
     if (queue->empty_waiters) {
@@ -297,7 +301,9 @@ APR_DECLARE(apr_status_t) apr_queue_pop(
     *data = queue->data[queue->out];
     queue->nelts--;
 
-    queue->out = (queue->out + 1) % queue->bounds;
+    queue->out++;
+    if (queue->out >= queue->bounds)
+        queue->out -= queue->bounds;
     if (queue->full_waiters) {
         Q_DBG("signal !full", queue);
         rv = apr_thread_cond_signal(queue->not_full);
@@ -337,7 +343,9 @@ APR_DECLARE(apr_status_t) apr_queue_tryp
     *data = queue->data[queue->out];
     queue->nelts--;
 
-    queue->out = (queue->out + 1) % queue->bounds;
+    queue->out++;
+    if (queue->out >= queue->bounds)
+        queue->out -= queue->bounds;
     if (queue->full_waiters) {
         Q_DBG("signal !full", queue);
         rv = apr_thread_cond_signal(queue->not_full);



Mime
View raw message