aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-12 00:50:23 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-12 00:51:53 +0100
commit16494f557fd742ca484943407888fb8a349c01ee (patch)
tree353f1aeeec49b21fd47c9ff7ca8658e27e555863
parent69171dc466ab94daf14e7560efe92c5050b0c1b1 (diff)
downloadbusybox-w32-16494f557fd742ca484943407888fb8a349c01ee.tar.gz
busybox-w32-16494f557fd742ca484943407888fb8a349c01ee.tar.bz2
busybox-w32-16494f557fd742ca484943407888fb8a349c01ee.zip
bc: simplify zbc_program_logical()
function old new delta bc_program_exec 3918 3876 -42 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-42) Total: -42 bytes text data bss dec hex filename 982061 485 7296 989842 f1a92 busybox_old 982019 485 7296 989800 f1a68 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 791275c8c..8426998d0 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -5793,8 +5793,7 @@ static BC_STATUS zbc_program_logical(char inst)
5793 BcStatus s; 5793 BcStatus s;
5794 BcResult *opd1, *opd2, res; 5794 BcResult *opd1, *opd2, res;
5795 BcNum *n1, *n2; 5795 BcNum *n1, *n2;
5796 bool cond = 0; 5796 ssize_t cond;
5797 ssize_t cmp;
5798 5797
5799 s = zbc_program_binOpPrep(&opd1, &n1, &opd2, &n2, false); 5798 s = zbc_program_binOpPrep(&opd1, &n1, &opd2, &n2, false);
5800 if (s) RETURN_STATUS(s); 5799 if (s) RETURN_STATUS(s);
@@ -5806,25 +5805,25 @@ static BC_STATUS zbc_program_logical(char inst)
5806 else if (inst == BC_INST_BOOL_OR) 5805 else if (inst == BC_INST_BOOL_OR)
5807 cond = bc_num_cmp(n1, &G.prog.zero) || bc_num_cmp(n2, &G.prog.zero); 5806 cond = bc_num_cmp(n1, &G.prog.zero) || bc_num_cmp(n2, &G.prog.zero);
5808 else { 5807 else {
5809 cmp = bc_num_cmp(n1, n2); 5808 cond = bc_num_cmp(n1, n2);
5810 switch (inst) { 5809 switch (inst) {
5811 case BC_INST_REL_EQ: 5810 case BC_INST_REL_EQ:
5812 cond = cmp == 0; 5811 cond = (cond == 0);
5813 break; 5812 break;
5814 case BC_INST_REL_LE: 5813 case BC_INST_REL_LE:
5815 cond = cmp <= 0; 5814 cond = (cond <= 0);
5816 break; 5815 break;
5817 case BC_INST_REL_GE: 5816 case BC_INST_REL_GE:
5818 cond = cmp >= 0; 5817 cond = (cond >= 0);
5819 break;
5820 case BC_INST_REL_NE:
5821 cond = cmp != 0;
5822 break; 5818 break;
5823 case BC_INST_REL_LT: 5819 case BC_INST_REL_LT:
5824 cond = cmp < 0; 5820 cond = (cond < 0);
5825 break; 5821 break;
5826 case BC_INST_REL_GT: 5822 case BC_INST_REL_GT:
5827 cond = cmp > 0; 5823 cond = (cond > 0);
5824 break;
5825 default: // = case BC_INST_REL_NE:
5826 //cond = (cond != 0); - not needed
5828 break; 5827 break;
5829 } 5828 }
5830 } 5829 }