apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r551922 - /apr/apr/trunk/strings/apr_snprintf.c
Date Fri, 29 Jun 2007 15:11:33 GMT
Author: davi
Date: Fri Jun 29 08:11:32 2007
New Revision: 551922

URL: http://svn.apache.org/viewvc?view=rev&rev=551922
Log:
Early assignment of the to-be-converted number yields better code and avoids
ugly casts.

Modified:
    apr/apr/trunk/strings/apr_snprintf.c

Modified: apr/apr/trunk/strings/apr_snprintf.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/strings/apr_snprintf.c?view=diff&rev=551922&r1=551921&r2=551922
==============================================================================
--- apr/apr/trunk/strings/apr_snprintf.c (original)
+++ apr/apr/trunk/strings/apr_snprintf.c Fri Jun 29 08:11:32 2007
@@ -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;
     }
 
     /*



Mime
View raw message