bc: rewrite "block flag stack" using simple realloc'ed byte array
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 14 Dec 2018 23:39:17 +0000 (00:39 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 14 Dec 2018 23:49:16 +0000 (00:49 +0100)
commit7db384338a803fc74a0e8eb62e9369e10a49ffdb
tree3ffc6b10de2c8f9d24b5e72042fe659cfc35c86d
parentf10f17f8d3ee77c469fc57634a458e8a45aeb681
bc: rewrite "block flag stack" using simple realloc'ed byte array

Each access to current top flag took a function call + fetch of three data items
+ multiplication and some additions + and then following the resulting pointer.

After the change, it is: fetch pointer value + one byte access via this pointer.

function                                             old     new   delta
bc_parse_startBody                                    45      49      +4
bc_parse_free                                         46      47      +1
zbc_parse_auto                                       188     185      -3
bc_parse_push                                         14      11      -3
bc_vm_run                                            398     394      -4
zbc_vm_process                                        63      58      -5
zdc_parse_expr                                       638     632      -6
zbc_parse_body                                       101      95      -6
bc_parse_addFunc                                      31      25      -6
bc_parse_noElse                                       56      48      -8
zcommon_parse                                        341     331     -10
zbc_parse_else                                       134     123     -11
bc_parse_create                                      124     108     -16
zbc_parse_text_init                                  123     104     -19
zbc_parse_endBody                                    292     252     -40
zbc_parse_stmt                                      1479    1420     -59
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/14 up/down: 5/-196)          Total: -191 bytes
   text    data     bss     dec     hex filename
 979880     485    7296  987661   f120d busybox_old
 979689     485    7296  987470   f114e busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/bc.c