[git commit] shell/math: eliminate redundant endofname()
Denys Vlasenko
vda.linux at googlemail.com
Sun Jun 18 17:03:05 UTC 2023
commit: https://git.busybox.net/busybox/commit/?id=8309c9159f7d8ee8b0f6f4b401750c5a03a4b0b9
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
evaluate_string 1486 1498 +12
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
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));
More information about the busybox-cvs
mailing list