Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 29129 invoked from network); 27 Jan 2011 19:46:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Jan 2011 19:46:05 -0000 Received: (qmail 77333 invoked by uid 500); 27 Jan 2011 19:46:05 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 77275 invoked by uid 500); 27 Jan 2011 19:46:05 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 77268 invoked by uid 99); 27 Jan 2011 19:46:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Jan 2011 19:46:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Jan 2011 19:46:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B370223889E0; Thu, 27 Jan 2011 19:45:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1064279 - /apr/apr-util/branches/1.3.x/misc/apr_queue.c Date: Thu, 27 Jan 2011 19:45:44 -0000 To: commits@apr.apache.org From: jim@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110127194544.B370223889E0@eris.apache.org> 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);