diff options
| author | Ron Yorston <rmy@pobox.com> | 2024-04-06 09:50:42 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2024-07-14 01:12:54 +0200 |
| commit | 371fe9f71d445d18be28c82a2a6d82115c8af19d (patch) | |
| tree | 5e0d3048ee2a64ec6efd2b334d1c072fd2e357c0 | |
| parent | e4b5ccd13bb59eaaec6aa7f22655cc469f8900a2 (diff) | |
| download | busybox-w32-371fe9f71d445d18be28c82a2a6d82115c8af19d.tar.gz busybox-w32-371fe9f71d445d18be28c82a2a6d82115c8af19d.tar.bz2 busybox-w32-371fe9f71d445d18be28c82a2a6d82115c8af19d.zip | |
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>
| -rw-r--r-- | shell/ash.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/shell/ash.c b/shell/ash.c index 9da3e956a..bbd730770 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
| @@ -2327,9 +2327,11 @@ initvar(void) | |||
| 2327 | } | 2327 | } |
| 2328 | 2328 | ||
| 2329 | static struct var ** | 2329 | static struct var ** |
| 2330 | findvar(struct var **vpp, const char *name) | 2330 | findvar(const char *name) |
| 2331 | { | 2331 | { |
| 2332 | for (; *vpp; vpp = &(*vpp)->next) { | 2332 | struct var **vpp; |
| 2333 | |||
| 2334 | for (vpp = hashvar(name); *vpp; vpp = &(*vpp)->next) { | ||
| 2333 | if (varcmp((*vpp)->var_text, name) == 0) { | 2335 | if (varcmp((*vpp)->var_text, name) == 0) { |
| 2334 | break; | 2336 | break; |
| 2335 | } | 2337 | } |
| @@ -2345,7 +2347,7 @@ lookupvar(const char *name) | |||
| 2345 | { | 2347 | { |
| 2346 | struct var *v; | 2348 | struct var *v; |
| 2347 | 2349 | ||
| 2348 | v = *findvar(hashvar(name), name); | 2350 | v = *findvar(name); |
| 2349 | if (v) { | 2351 | if (v) { |
| 2350 | #if ENABLE_ASH_RANDOM_SUPPORT || BASH_EPOCH_VARS | 2352 | #if ENABLE_ASH_RANDOM_SUPPORT || BASH_EPOCH_VARS |
| 2351 | /* | 2353 | /* |
| @@ -2412,9 +2414,8 @@ setvareq(char *s, int flags) | |||
| 2412 | { | 2414 | { |
| 2413 | struct var *vp, **vpp; | 2415 | struct var *vp, **vpp; |
| 2414 | 2416 | ||
| 2415 | vpp = hashvar(s); | ||
| 2416 | flags |= (VEXPORT & (((unsigned) (1 - aflag)) - 1)); | 2417 | flags |= (VEXPORT & (((unsigned) (1 - aflag)) - 1)); |
| 2417 | vpp = findvar(vpp, s); | 2418 | vpp = findvar(s); |
| 2418 | vp = *vpp; | 2419 | vp = *vpp; |
| 2419 | if (vp) { | 2420 | if (vp) { |
| 2420 | if ((vp->flags & (VREADONLY|VDYNAMIC)) == VREADONLY) { | 2421 | if ((vp->flags & (VREADONLY|VDYNAMIC)) == VREADONLY) { |
| @@ -9978,7 +9979,6 @@ static void | |||
| 9978 | mklocal(char *name, int flags) | 9979 | mklocal(char *name, int flags) |
| 9979 | { | 9980 | { |
| 9980 | struct localvar *lvp; | 9981 | struct localvar *lvp; |
| 9981 | struct var **vpp; | ||
| 9982 | struct var *vp; | 9982 | struct var *vp; |
| 9983 | char *eq = strchr(name, '='); | 9983 | char *eq = strchr(name, '='); |
| 9984 | 9984 | ||
| @@ -10007,8 +10007,7 @@ mklocal(char *name, int flags) | |||
| 10007 | lvp->text = memcpy(p, optlist, sizeof(optlist)); | 10007 | lvp->text = memcpy(p, optlist, sizeof(optlist)); |
| 10008 | vp = NULL; | 10008 | vp = NULL; |
| 10009 | } else { | 10009 | } else { |
| 10010 | vpp = hashvar(name); | 10010 | vp = *findvar(name); |
| 10011 | vp = *findvar(vpp, name); | ||
| 10012 | if (vp == NULL) { | 10011 | if (vp == NULL) { |
| 10013 | /* variable did not exist yet */ | 10012 | /* variable did not exist yet */ |
| 10014 | if (eq) | 10013 | if (eq) |
| @@ -14156,7 +14155,7 @@ exportcmd(int argc UNUSED_PARAM, char **argv) | |||
| 14156 | if (p != NULL) { | 14155 | if (p != NULL) { |
| 14157 | p++; | 14156 | p++; |
| 14158 | } else { | 14157 | } else { |
| 14159 | vp = *findvar(hashvar(name), name); | 14158 | vp = *findvar(name); |
| 14160 | if (vp) { | 14159 | if (vp) { |
| 14161 | vp->flags = ((vp->flags | flag) & flag_off); | 14160 | vp->flags = ((vp->flags | flag) & flag_off); |
| 14162 | continue; | 14161 | continue; |
