From 8309c9159f7d8ee8b0f6f4b401750c5a03a4b0b9 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 18 Jun 2023 18:58:22 +0200 Subject: shell/math: eliminate redundant endofname() function old new delta evaluate_string 1486 1498 +12 Signed-off-by: Denys Vlasenko --- shell/math.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/shell/math.c b/shell/math.c index fee325307..cb702b7f4 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)); -- cgit v1.2.3-55-g6feb