diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-18 18:58:22 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-18 19:03:05 +0200 |
commit | 8309c9159f7d8ee8b0f6f4b401750c5a03a4b0b9 (patch) | |
tree | 38f2b3ce36fc8b11e3960e1fef3e49f39f55744a | |
parent | b61fd8ec5a2e3b728c05a72b603fb4255b1022da (diff) | |
download | busybox-w32-8309c9159f7d8ee8b0f6f4b401750c5a03a4b0b9.tar.gz busybox-w32-8309c9159f7d8ee8b0f6f4b401750c5a03a4b0b9.tar.bz2 busybox-w32-8309c9159f7d8ee8b0f6f4b401750c5a03a4b0b9.zip |
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 fee325307..cb702b7f4 100644 --- a/shell/math.c +++ b/shell/math.c | |||
@@ -265,19 +265,18 @@ static arith_t | |||
265 | evaluate_string(arith_state_t *math_state, const char *expr); | 265 | evaluate_string(arith_state_t *math_state, const char *expr); |
266 | 266 | ||
267 | static arith_t | 267 | static arith_t |
268 | arith_lookup_val(arith_state_t *math_state, const char *name) | 268 | arith_lookup_val(arith_state_t *math_state, const char *name, char *endname) |
269 | { | 269 | { |
270 | char c; | 270 | char c; |
271 | const char *p; | 271 | const char *p; |
272 | char *e = (char*)endofname(name); | ||
273 | 272 | ||
274 | c = *e; | 273 | c = *endname; |
275 | *e = '\0'; | 274 | *endname = '\0'; |
276 | p = math_state->lookupvar(name); | 275 | p = math_state->lookupvar(name); |
277 | *e = c; | 276 | *endname = c; |
278 | if (p) { | 277 | if (p) { |
279 | arith_t val; | 278 | arith_t val; |
280 | size_t len = e - name; | 279 | size_t len = endname - name; |
281 | remembered_name *cur; | 280 | remembered_name *cur; |
282 | remembered_name remember; | 281 | remembered_name remember; |
283 | 282 | ||
@@ -685,9 +684,10 @@ evaluate_string(arith_state_t *math_state, const char *expr) | |||
685 | || expr[1] == '=' /* or "==..." */ | 684 | || expr[1] == '=' /* or "==..." */ |
686 | ) { | 685 | ) { |
687 | /* Evaluate variable to value */ | 686 | /* Evaluate variable to value */ |
688 | numstackptr->val = arith_lookup_val(math_state, numstackptr->var_name); | 687 | arith_t val = arith_lookup_val(math_state, numstackptr->var_name, (char*)p); |
689 | if (math_state->errmsg) | 688 | if (math_state->errmsg) |
690 | return numstackptr->val; /* -1 */ | 689 | return val; /* -1 */ |
690 | numstackptr->val = val; | ||
691 | } | 691 | } |
692 | } else { | 692 | } else { |
693 | dbg("[%d] var:IGNORED", (int)(numstackptr - numstack)); | 693 | dbg("[%d] var:IGNORED", (int)(numstackptr - numstack)); |