diff options
author | Denys Vlasenko | 2023-06-18 18:58:22 +0200 |
---|---|---|
committer | Denys Vlasenko | 2023-06-18 19:03:05 +0200 |
commit | 8309c9159f7d8ee8b0f6f4b401750c5a03a4b0b9 (patch) | |
tree | 38f2b3ce36fc8b11e3960e1fef3e49f39f55744a | |
parent | b61fd8ec5a2e3b728c05a72b603fb4255b1022da (diff) | |
download | busybox-8309c9159f7d8ee8b0f6f4b401750c5a03a4b0b9.zip busybox-8309c9159f7d8ee8b0f6f4b401750c5a03a4b0b9.tar.gz |
shell/math: eliminate redundant endofname()
function old new delta
evaluate_string 1486 1498 +12
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/math.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/shell/math.c b/shell/math.c index fee3253..cb702b7 100644 --- a/shell/math.c +++ b/shell/math.c @@ -265,19 +265,18 @@ static arith_t evaluate_string(arith_state_t *math_state, const char *expr); static arith_t -arith_lookup_val(arith_state_t *math_state, const char *name) +arith_lookup_val(arith_state_t *math_state, const char *name, char *endname) { char c; const char *p; - char *e = (char*)endofname(name); - c = *e; - *e = '\0'; + c = *endname; + *endname = '\0'; p = math_state->lookupvar(name); - *e = c; + *endname = c; if (p) { arith_t val; - size_t len = e - name; + size_t len = endname - name; remembered_name *cur; remembered_name remember; @@ -685,9 +684,10 @@ evaluate_string(arith_state_t *math_state, const char *expr) || expr[1] == '=' /* or "==..." */ ) { /* Evaluate variable to value */ - numstackptr->val = arith_lookup_val(math_state, numstackptr->var_name); + arith_t val = arith_lookup_val(math_state, numstackptr->var_name, (char*)p); if (math_state->errmsg) - return numstackptr->val; /* -1 */ + return val; /* -1 */ + numstackptr->val = val; } } else { dbg("[%d] var:IGNORED", (int)(numstackptr - numstack)); |