[git commit] shell/math: remove now-unused second_val

Denys Vlasenko vda.linux at googlemail.com
Wed Jun 14 09:10:45 UTC 2023


commit: https://git.busybox.net/busybox/commit/?id=5febdb122357dbe39e236c9e93d06dab328edb45
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
arith_apply                                         1137    1134      -3
evaluate_string                                     1101    1095      -6
arith_lookup_val                                     150     143      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-16)             Total: -16 bytes

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/math.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/shell/math.c b/shell/math.c
index 2b7a3494f..fa22bc400 100644
--- a/shell/math.c
+++ b/shell/math.c
@@ -246,24 +246,11 @@ is_right_associative(operator prec)
 
 typedef struct {
 	arith_t val;
-	/* We acquire second_val only when "expr1 : expr2" part
-	 * of ternary ?: op is evaluated.
-	 * We treat ?: as two binary ops: (expr ? (expr1 : expr2)).
-	 * ':' produces a new value which has two parts, val and second_val;
-	 * then '?' selects one of them based on its left side.
-	 */
-	arith_t second_val;
-#define SECOND_VAL_VALID ((char*)(intptr_t)-1)
-	/* If NULL then it's just a number, if SECOND_VAL_VALID,
-	 * it's a result of "expr : expr", else it's a named variable.
-	 * (We use SECOND_VAL_VALID instead of a bit flag to keep
-	 * var_or_num_t smaller, we allocate a lot of them on stack).
-	 */
 	char *var_name;
 } var_or_num_t;
 
-#define VALID_NAME(name) ((name) && (name) != SECOND_VAL_VALID)
-#define NOT_NAME(name)   (!(name) || (name) == SECOND_VAL_VALID)
+#define VALID_NAME(name) (name)
+#define NOT_NAME(name)   (!(name))
 
 
 typedef struct remembered_name {
@@ -854,11 +841,7 @@ evaluate_string(arith_state_t *math_state, const char *expr)
 				errmsg = arith_apply(math_state, prev_op, numstack, &numstackptr);
 				if (errmsg)
 					goto err_with_custom_msg;
-dbg("    numstack:%d val:%lld %lld %p", (int)(numstackptr - numstack),
-	numstackptr[-1].val,
-	numstackptr[-1].var_name == SECOND_VAL_VALID ? numstackptr[-1].second_val : 0,
-	numstackptr[-1].var_name
-);
+dbg("    numstack:%d val:%lld '%s'", (int)(numstackptr - numstack), numstackptr[-1].val, numstackptr[-1].var_name);
 				/* For ternary ?: we need to remove ? from opstack too, not just : */
 				if (prev_op == TOK_CONDITIONAL_SEP) {
 					// This is caught in arith_apply()


More information about the busybox-cvs mailing list