diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-18 12:43:21 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-18 12:43:21 +0100 |
commit | 71c82d1d8ca0617290600050728feda906878115 (patch) | |
tree | 5f5f3685b46ef986083daa2df033d003a33fbd3c | |
parent | e2e6ffd3c5e229ef386ca22e467c6553e570c55a (diff) | |
download | busybox-w32-71c82d1d8ca0617290600050728feda906878115.tar.gz busybox-w32-71c82d1d8ca0617290600050728feda906878115.tar.bz2 busybox-w32-71c82d1d8ca0617290600050728feda906878115.zip |
bc: rewrite another for() loop
function old new delta
zbc_num_d 570 563 -7
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | miscutils/bc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 6c63c1703..0cd8ba6b4 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -1933,7 +1933,6 @@ static FAST_FUNC BC_STATUS zbc_num_d(BcNum *a, BcNum *b, BcNum *restrict c, size | |||
1933 | BcDig *n, *p, q; | 1933 | BcDig *n, *p, q; |
1934 | size_t len, end, i; | 1934 | size_t len, end, i; |
1935 | BcNum cp; | 1935 | BcNum cp; |
1936 | bool zero = true; | ||
1937 | 1936 | ||
1938 | if (b->len == 0) | 1937 | if (b->len == 0) |
1939 | RETURN_STATUS(bc_error("divide by zero")); | 1938 | RETURN_STATUS(bc_error("divide by zero")); |
@@ -1961,8 +1960,13 @@ static FAST_FUNC BC_STATUS zbc_num_d(BcNum *a, BcNum *b, BcNum *restrict c, size | |||
1961 | if (scale > cp.rdx) bc_num_extend(&cp, scale - cp.rdx); | 1960 | if (scale > cp.rdx) bc_num_extend(&cp, scale - cp.rdx); |
1962 | 1961 | ||
1963 | if (b->rdx == b->len) { | 1962 | if (b->rdx == b->len) { |
1964 | for (i = 0; zero && i < len; ++i) zero = !b->num[len - i - 1]; | 1963 | for (;;) { |
1965 | len -= i - 1; | 1964 | if (len == 0) break; |
1965 | len--; | ||
1966 | if (b->num[len] != 0) | ||
1967 | break; | ||
1968 | } | ||
1969 | len++; | ||
1966 | } | 1970 | } |
1967 | 1971 | ||
1968 | if (cp.cap == cp.len) bc_num_expand(&cp, cp.len + 1); | 1972 | if (cp.cap == cp.len) bc_num_expand(&cp, cp.len + 1); |