summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko2018-12-16 20:32:58 +0100
committerDenys Vlasenko2018-12-16 20:32:58 +0100
commite6c40c48d96169ff27471c63c33e568e96fd5b82 (patch)
tree60c514bebe1dcf5ef568351492a222495a4b7e86 /miscutils
parent563d93c9a4e2a784dfbec6703c572fb88eb99332 (diff)
downloadbusybox-e6c40c48d96169ff27471c63c33e568e96fd5b82.zip
busybox-e6c40c48d96169ff27471c63c33e568e96fd5b82.tar.gz
bc: simplify bc_parse_pushName(), do not free name in it - avoids one strdup
function old new delta zbc_parse_name 511 509 -2 zdc_parse_register 50 43 -7 bc_parse_pushName 61 39 -22 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-31) Total: -31 bytes text data bss dec hex filename 982183 485 7296 989964 f1b0c busybox_old 982152 485 7296 989933 f1aed busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 8aaeeaf..6e39aee 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -3529,12 +3529,9 @@ static void bc_parse_push(BcParse *p, char i)
static void bc_parse_pushName(BcParse *p, char *name)
{
- size_t i = 0, len = strlen(name);
-
- for (; i < len; ++i) bc_parse_push(p, name[i]);
+ while (*name)
+ bc_parse_push(p, *name++);
bc_parse_push(p, BC_PARSE_STREND);
-
- free(name);
}
static void bc_parse_pushIndex(BcParse *p, size_t idx)
@@ -3828,6 +3825,7 @@ static BC_STATUS zbc_parse_name(BcParse *p, BcInst *type, uint8_t flags)
if (s) goto err;
bc_parse_push(p, *type);
bc_parse_pushName(p, name);
+ free(name);
}
else if (p->l.t.t == BC_LEX_LPAREN) {
if (flags & BC_PARSE_NOCALL) {
@@ -3840,6 +3838,7 @@ static BC_STATUS zbc_parse_name(BcParse *p, BcInst *type, uint8_t flags)
*type = BC_INST_VAR;
bc_parse_push(p, BC_INST_VAR);
bc_parse_pushName(p, name);
+ free(name);
}
RETURN_STATUS(s);
@@ -4970,14 +4969,12 @@ static BC_STATUS zbc_parse_expr(BcParse *p, uint8_t flags, BcParseNext next)
static BC_STATUS zdc_parse_register(BcParse *p)
{
BcStatus s;
- char *name;
s = zbc_lex_next(&p->l);
if (s) RETURN_STATUS(s);
if (p->l.t.t != BC_LEX_NAME) RETURN_STATUS(bc_error_bad_token());
- name = xstrdup(p->l.t.v.v);
- bc_parse_pushName(p, name);
+ bc_parse_pushName(p, p->l.t.v.v);
RETURN_STATUS(s);
}