projects
/
oweals
/
busybox.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
44d79d8
)
bc: simplify bc_program_len()
author
Denys Vlasenko
<vda.linux@googlemail.com>
Mon, 10 Dec 2018 11:57:01 +0000
(12:57 +0100)
committer
Denys Vlasenko
<vda.linux@googlemail.com>
Mon, 10 Dec 2018 11:57:01 +0000
(12:57 +0100)
function old new delta
bc_program_len 42 34 -8
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/bc.c
patch
|
blob
|
history
diff --git
a/miscutils/bc.c
b/miscutils/bc.c
index 1879581e37658adb7f5b88bacbb66f867eb1de84..afd5c8d0e7e83ee38e18ac42548f45988a6879e2 100644
(file)
--- a/
miscutils/bc.c
+++ b/
miscutils/bc.c
@@
-6254,12
+6254,14
@@
static unsigned long bc_program_scale(BcNum *n)
static unsigned long bc_program_len(BcNum *n)
{
- unsigned long len = n->len;
- size_t i;
-
- if (n->rdx != n->len) return len;
- for (i = n->len - 1; i < n->len && n->num[i] == 0; --len, --i);
+ size_t len = n->len;
+ if (n->rdx != len) return len;
+ for (;;) {
+ if (len == 0) break;
+ len--;
+ if (n->num[len] != 0) break;
+ }
return len;
}