[git commit] bc: rewrite another for() loop
Denys Vlasenko
vda.linux at googlemail.com
Tue Dec 18 11:43:21 UTC 2018
commit: https://git.busybox.net/busybox/commit/?id=71c82d1d8ca0617290600050728feda906878115
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
zbc_num_d 570 563 -7
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
miscutils/bc.c | 10 +++++++---
1 file 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
BcDig *n, *p, q;
size_t len, end, i;
BcNum cp;
- bool zero = true;
if (b->len == 0)
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
if (scale > cp.rdx) bc_num_extend(&cp, scale - cp.rdx);
if (b->rdx == b->len) {
- for (i = 0; zero && i < len; ++i) zero = !b->num[len - i - 1];
- len -= i - 1;
+ for (;;) {
+ if (len == 0) break;
+ len--;
+ if (b->num[len] != 0)
+ break;
+ }
+ len++;
}
if (cp.cap == cp.len) bc_num_expand(&cp, cp.len + 1);
More information about the busybox-cvs
mailing list