diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-18 15:49:42 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-18 15:49:42 +0100 |
commit | 3f940c9c707904df545c148065f720d33e805aed (patch) | |
tree | af6e53ef36b07137014b59c36eceed171f98ed4a | |
parent | 55f3cab7e9f61c1e9fc342f2d245d6b055a08b84 (diff) | |
download | busybox-w32-3f940c9c707904df545c148065f720d33e805aed.tar.gz busybox-w32-3f940c9c707904df545c148065f720d33e805aed.tar.bz2 busybox-w32-3f940c9c707904df545c148065f720d33e805aed.zip |
bc: shrink bc_program_index()
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@googlemail.com>
-rw-r--r-- | miscutils/bc.c | 15 |
1 files 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: | |||
5256 | 5256 | ||
5257 | static size_t bc_program_index(char *code, size_t *bgn) | 5257 | static size_t bc_program_index(char *code, size_t *bgn) |
5258 | { | 5258 | { |
5259 | char amt = code[(*bgn)++], i = 0; | 5259 | unsigned char *bytes = (void*)(code + *bgn); |
5260 | size_t res = 0; | 5260 | unsigned amt; |
5261 | unsigned i; | ||
5262 | size_t res; | ||
5263 | |||
5264 | amt = *bytes++; | ||
5265 | *bgn += amt + 1; | ||
5261 | 5266 | ||
5262 | for (; i < amt; ++i, ++(*bgn)) | 5267 | amt *= 8; |
5263 | res |= (((size_t)((int) code[*bgn]) & UCHAR_MAX) << (i * CHAR_BIT)); | 5268 | res = 0; |
5269 | for (i = 0; i < amt; i += 8) | ||
5270 | res |= (size_t)(*bytes++) << i; | ||
5264 | 5271 | ||
5265 | return res; | 5272 | return res; |
5266 | } | 5273 | } |