You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by ji...@apache.org on 2011/01/27 20:45:44 UTC
svn commit: r1064279 - /apr/apr-util/branches/1.3.x/misc/apr_queue.c
Author: jim
Date: Thu Jan 27 19:45:44 2011
New Revision: 1064279
URL: http://svn.apache.org/viewvc?rev=1064279&view=rev
Log:
replace expensive % with faster (2-4x) functional equiv.
Modified:
apr/apr-util/branches/1.3.x/misc/apr_queue.c
Modified: apr/apr-util/branches/1.3.x/misc/apr_queue.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/misc/apr_queue.c?rev=1064279&r1=1064278&r2=1064279&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/misc/apr_queue.c (original)
+++ apr/apr-util/branches/1.3.x/misc/apr_queue.c Thu Jan 27 19:45:44 2011
@@ -185,7 +185,9 @@ APU_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 @@ APU_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 @@ APU_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 @@ APU_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);