mirror of https://github.com/mirror/busybox.git
ash: move hashvar() calls into findvar()
dash has accepted a patch to remove the first argument of findvar(). It's commit e85e972 (var: move hashvar() calls into findvar()). Apply the same change to BusyBox ash. function old new delta findvar 35 40 +5 mklocal 268 261 -7 exportcmd 164 157 -7 setvareq 319 310 -9 lookupvar 150 141 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/4 up/down: 5/-32) Total: -27 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>master
parent
e4b5ccd13b
commit
371fe9f71d
17
shell/ash.c
17
shell/ash.c
|
@ -2327,9 +2327,11 @@ initvar(void)
|
|||
}
|
||||
|
||||
static struct var **
|
||||
findvar(struct var **vpp, const char *name)
|
||||
findvar(const char *name)
|
||||
{
|
||||
for (; *vpp; vpp = &(*vpp)->next) {
|
||||
struct var **vpp;
|
||||
|
||||
for (vpp = hashvar(name); *vpp; vpp = &(*vpp)->next) {
|
||||
if (varcmp((*vpp)->var_text, name) == 0) {
|
||||
break;
|
||||
}
|
||||
|
@ -2345,7 +2347,7 @@ lookupvar(const char *name)
|
|||
{
|
||||
struct var *v;
|
||||
|
||||
v = *findvar(hashvar(name), name);
|
||||
v = *findvar(name);
|
||||
if (v) {
|
||||
#if ENABLE_ASH_RANDOM_SUPPORT || BASH_EPOCH_VARS
|
||||
/*
|
||||
|
@ -2412,9 +2414,8 @@ setvareq(char *s, int flags)
|
|||
{
|
||||
struct var *vp, **vpp;
|
||||
|
||||
vpp = hashvar(s);
|
||||
flags |= (VEXPORT & (((unsigned) (1 - aflag)) - 1));
|
||||
vpp = findvar(vpp, s);
|
||||
vpp = findvar(s);
|
||||
vp = *vpp;
|
||||
if (vp) {
|
||||
if ((vp->flags & (VREADONLY|VDYNAMIC)) == VREADONLY) {
|
||||
|
@ -9978,7 +9979,6 @@ static void
|
|||
mklocal(char *name, int flags)
|
||||
{
|
||||
struct localvar *lvp;
|
||||
struct var **vpp;
|
||||
struct var *vp;
|
||||
char *eq = strchr(name, '=');
|
||||
|
||||
|
@ -10007,8 +10007,7 @@ mklocal(char *name, int flags)
|
|||
lvp->text = memcpy(p, optlist, sizeof(optlist));
|
||||
vp = NULL;
|
||||
} else {
|
||||
vpp = hashvar(name);
|
||||
vp = *findvar(vpp, name);
|
||||
vp = *findvar(name);
|
||||
if (vp == NULL) {
|
||||
/* variable did not exist yet */
|
||||
if (eq)
|
||||
|
@ -14156,7 +14155,7 @@ exportcmd(int argc UNUSED_PARAM, char **argv)
|
|||
if (p != NULL) {
|
||||
p++;
|
||||
} else {
|
||||
vp = *findvar(hashvar(name), name);
|
||||
vp = *findvar(name);
|
||||
if (vp) {
|
||||
vp->flags = ((vp->flags | flag) & flag_off);
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue