From 9790eb73c8b7ed1a1015f58e1fe85de0508c0526 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 28 May 2023 13:32:07 +0200 Subject: libbb/dump: code shrink function old new delta .rodata 105252 105246 -6 Signed-off-by: Denys Vlasenko --- libbb/dump.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libbb/dump.c b/libbb/dump.c index 70f15c9bd..b406a2428 100644 --- a/libbb/dump.c +++ b/libbb/dump.c @@ -47,8 +47,10 @@ typedef struct priv_dumper_t { static const char dot_flags_width_chars[] ALIGN1 = ".#-+ 0123456789"; static const char size_conv_str[] ALIGN1 = -"\x1\x4\x4\x4\x4\x4\x4\x8\x8\x8\x8\010cdiouxXeEfgG"; - +"\x1\x4\x4\x4\x4\x4\x4\x8\x8\x8\x8\x8""cdiouxXeEfgG"; +/* c d i o u x X e E f g G - bytes contain 'bcnt' for the type */ +#define SCS_OFS 12 +#define float_convs (size_conv_str + SCS_OFS + sizeof("cdiouxX")-1) static const char int_convs[] ALIGN1 = "diouxX"; dumper_t* FAST_FUNC alloc_dumper(void) @@ -88,7 +90,7 @@ static NOINLINE int bb_dump_size(FS *fs) while (isdigit(*++fmt)) continue; } - p = strchr(size_conv_str + 12, *fmt); + p = strchr(size_conv_str + SCS_OFS, *fmt); if (!p) { if (*fmt == 's') { bcnt += prec; @@ -100,7 +102,7 @@ static NOINLINE int bb_dump_size(FS *fs) } } } else { - bcnt += p[-12]; + bcnt += p[-SCS_OFS]; } } cur_size += bcnt * fu->reps; @@ -204,7 +206,7 @@ static NOINLINE void rewrite(priv_dumper_t *dumper, FS *fs) if (strchr(int_convs, *p1)) { /* %d etc */ goto DO_INT_CONV; } else - if (strchr("eEfgG", *p1)) { /* floating point */ + if (strchr(float_convs, *p1)) { /* floating point */ pr->flags = F_DBL; byte_count_str = "\010\004"; goto DO_BYTE_COUNT; -- cgit v1.2.3-55-g6feb