Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 17053 invoked from network); 27 Apr 2007 14:37:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Apr 2007 14:37:32 -0000 Received: (qmail 43971 invoked by uid 500); 27 Apr 2007 14:37:33 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 43932 invoked by uid 500); 27 Apr 2007 14:37:33 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 43787 invoked by uid 99); 27 Apr 2007 14:37:33 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Apr 2007 07:37:32 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [65.99.219.155] (HELO haxent.com) (65.99.219.155) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Apr 2007 07:37:24 -0700 Received: from karmic (unknown [201.21.180.98]) by haxent.com (Postfix) with ESMTP id A7F12388C6 for ; Fri, 27 Apr 2007 11:36:47 -0300 (BRT) Received: by karmic (Postfix, from userid 1000) id C08E02AC588; Fri, 27 Apr 2007 11:36:46 -0300 (BRT) Message-Id: <20070427143646.578120000@haxent.com.br> References: <20070427142918.108531000@haxent.com.br> User-Agent: quilt/0.45-1 Date: Fri, 27 Apr 2007 11:29:19 -0300 From: Davi Arnaut To: dev@apr.apache.org Subject: [patch 1/9] Early assignment yields better code Content-Disposition: inline; filename=apr-vformatter-quad.patch X-Virus-Checked: Checked by ClamAV on apache.org Early assignment of the to-be-converted number yields better code and avoids ugly casts. --- srclib/apr/strings/apr_snprintf.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) Index: 2.2.x/srclib/apr/strings/apr_snprintf.c =================================================================== --- 2.2.x.orig/srclib/apr/strings/apr_snprintf.c 2007-04-27 11:09:49.000000000 -0300 +++ 2.2.x/srclib/apr/strings/apr_snprintf.c 2007-04-27 11:09:49.000000000 -0300 @@ -343,10 +343,9 @@ register apr_size_t *len) { register char *p = buf_end; - register u_wide_int magnitude; + register u_wide_int magnitude = num; if (is_unsigned) { - magnitude = (u_wide_int) num; *is_negative = FALSE; } else { @@ -363,11 +362,8 @@ */ if (*is_negative) { wide_int t = num + 1; - magnitude = ((u_wide_int) -t) + 1; } - else - magnitude = (u_wide_int) num; } /* @@ -390,20 +386,19 @@ register apr_size_t *len) { register char *p = buf_end; - u_widest_int magnitude; + u_widest_int magnitude = num; /* * We see if we can use the faster non-quad version by checking the * number against the largest long value it can be. If <=, we * punt to the quicker version. */ - if (((u_widest_int)num <= (u_widest_int)ULONG_MAX && is_unsigned) + if ((magnitude <= ULONG_MAX && is_unsigned) || (num <= LONG_MAX && num >= LONG_MIN && !is_unsigned)) return(conv_10( (wide_int)num, is_unsigned, is_negative, buf_end, len)); if (is_unsigned) { - magnitude = (u_widest_int) num; *is_negative = FALSE; } else { @@ -420,11 +415,8 @@ */ if (*is_negative) { widest_int t = num + 1; - magnitude = ((u_widest_int) -t) + 1; } - else - magnitude = (u_widest_int) num; } /* --