[git commit] bc: shrink bc_program_index()
Denys Vlasenko
vda.linux at googlemail.com
Tue Dec 18 14:49:42 UTC 2018
commit: https://git.busybox.net/busybox/commit/?id=3f940c9c707904df545c148065f720d33e805aed
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
bc_program_index 66 47 -19
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-19) Total: -19 bytes
text data bss dec hex filename
981418 485 7296 989199 f180f busybox_old
981399 485 7296 989180 f17fc busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
miscutils/bc.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/miscutils/bc.c b/miscutils/bc.c
index eaa28a94a..2da7c317c 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -5256,11 +5256,18 @@ exec_err:
static size_t bc_program_index(char *code, size_t *bgn)
{
- char amt = code[(*bgn)++], i = 0;
- size_t res = 0;
+ unsigned char *bytes = (void*)(code + *bgn);
+ unsigned amt;
+ unsigned i;
+ size_t res;
+
+ amt = *bytes++;
+ *bgn += amt + 1;
- for (; i < amt; ++i, ++(*bgn))
- res |= (((size_t)((int) code[*bgn]) & UCHAR_MAX) << (i * CHAR_BIT));
+ amt *= 8;
+ res = 0;
+ for (i = 0; i < amt; i += 8)
+ res |= (size_t)(*bytes++) << i;
return res;
}
More information about the busybox-cvs
mailing list