diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-09 13:33:52 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-09 13:33:52 +0100 |
commit | 218ed1cf5466a37ade2a319e9335fb2c1ff19252 (patch) | |
tree | ff56c5debd8ebf7ecc84ff70169b0a4668b1dd65 /miscutils/bc.c | |
parent | 4a024c771992e274f46a8451647dc86f92a90999 (diff) | |
download | busybox-w32-218ed1cf5466a37ade2a319e9335fb2c1ff19252.tar.gz busybox-w32-218ed1cf5466a37ade2a319e9335fb2c1ff19252.tar.bz2 busybox-w32-218ed1cf5466a37ade2a319e9335fb2c1ff19252.zip |
bc: further simplify string-to-number conversion code
function old new delta
bc_program_index 66 64 -2
bc_program_num 983 963 -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-22) Total: -22 bytes
text data bss dec hex filename
985706 477 7296 993479 f28c7 busybox_old
985684 477 7296 993457 f28b1 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/bc.c')
-rw-r--r-- | miscutils/bc.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index c36486414..ca9506929 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -2246,8 +2246,14 @@ static void bc_num_parseDecimal(BcNum *n, const char *val) | |||
2246 | n->rdx = (size_t)((val + len) - (ptr + 1)); | 2246 | n->rdx = (size_t)((val + len) - (ptr + 1)); |
2247 | 2247 | ||
2248 | if (!zero) { | 2248 | if (!zero) { |
2249 | for (i = len - 1; i < len; ++n->len, i -= 1 + (i && val[i - 1] == '.')) | 2249 | i = len - 1; |
2250 | for (;;) { | ||
2250 | n->num[n->len] = val[i] - '0'; | 2251 | n->num[n->len] = val[i] - '0'; |
2252 | ++n->len; | ||
2253 | skip_dot: | ||
2254 | if ((ssize_t)--i == (ssize_t)-1) break; | ||
2255 | if (val[i] == '.') goto skip_dot; | ||
2256 | } | ||
2251 | } | 2257 | } |
2252 | } | 2258 | } |
2253 | 2259 | ||