diff options
author | davi <davi@13f79535-47bb-0310-9956-ffa450edef68> | 2007-06-29 15:11:32 +0000 |
---|---|---|
committer | davi <davi@13f79535-47bb-0310-9956-ffa450edef68> | 2007-06-29 15:11:32 +0000 |
commit | e4cd8f8042d00ab150314e21f4c64ca3729e2456 (patch) | |
tree | ec16be9f54835a3be33d0ee60069cd40ff46ed5b /strings | |
parent | b8ad51e34d36fabf7f84dffe6c52a6df5ef1014b (diff) | |
download | libapr-e4cd8f8042d00ab150314e21f4c64ca3729e2456.tar.gz |
Early assignment of the to-be-converted number yields better code and avoids
ugly casts.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@551922 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'strings')
-rw-r--r-- | strings/apr_snprintf.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/strings/apr_snprintf.c b/strings/apr_snprintf.c index bd39663ba..478e11263 100644 --- a/strings/apr_snprintf.c +++ b/strings/apr_snprintf.c @@ -343,10 +343,9 @@ static char *conv_10(register wide_int num, register bool_int is_unsigned, 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 @@ static char *conv_10(register wide_int num, register bool_int is_unsigned, */ if (*is_negative) { wide_int t = num + 1; - magnitude = ((u_wide_int) -t) + 1; } - else - magnitude = (u_wide_int) num; } /* @@ -390,20 +386,19 @@ static char *conv_10_quad(widest_int num, register bool_int is_unsigned, 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 @@ static char *conv_10_quad(widest_int num, register bool_int is_unsigned, */ if (*is_negative) { widest_int t = num + 1; - magnitude = ((u_widest_int) -t) + 1; } - else - magnitude = (u_widest_int) num; } /* |