diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-10 12:57:01 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-10 12:57:01 +0100 |
commit | a7f1a3654041ed4b1d4716f71a8396977aca8223 (patch) | |
tree | 122ec83245361be7d0ad96d13e2b20b2620f5772 | |
parent | 44d79d866dc4c9bb0c3bba47612feae78365a046 (diff) | |
download | busybox-w32-a7f1a3654041ed4b1d4716f71a8396977aca8223.tar.gz busybox-w32-a7f1a3654041ed4b1d4716f71a8396977aca8223.tar.bz2 busybox-w32-a7f1a3654041ed4b1d4716f71a8396977aca8223.zip |
bc: simplify bc_program_len()
function old new delta
bc_program_len 42 34 -8
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | miscutils/bc.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 1879581e3..afd5c8d0e 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -6254,12 +6254,14 @@ static unsigned long bc_program_scale(BcNum *n) | |||
6254 | 6254 | ||
6255 | static unsigned long bc_program_len(BcNum *n) | 6255 | static unsigned long bc_program_len(BcNum *n) |
6256 | { | 6256 | { |
6257 | unsigned long len = n->len; | 6257 | size_t len = n->len; |
6258 | size_t i; | ||
6259 | |||
6260 | if (n->rdx != n->len) return len; | ||
6261 | for (i = n->len - 1; i < n->len && n->num[i] == 0; --len, --i); | ||
6262 | 6258 | ||
6259 | if (n->rdx != len) return len; | ||
6260 | for (;;) { | ||
6261 | if (len == 0) break; | ||
6262 | len--; | ||
6263 | if (n->num[len] != 0) break; | ||
6264 | } | ||
6263 | return len; | 6265 | return len; |
6264 | } | 6266 | } |
6265 | 6267 | ||