From: Ron Yorston <rmy@frippery.org>
To: dash@vger.kernel.org
Subject: [PATCH] var: move hashvar() calls into findvar()
Date: Tue, 10 May 2022 09:16:55 +0100 [thread overview]
Message-ID: <627a1f77.3CLq0J9mI6V6UePB%rmy@frippery.org> (raw)
The first argument to findvar() is always obtained by a call to
hashvar(), the return value of which is otherwise unused.
Signed-off-by: Ron Yorston <rmy@frippery.org>
---
src/var.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/var.c b/src/var.c
index ef9c2bd..e301fe5 100644
--- a/src/var.c
+++ b/src/var.c
@@ -107,7 +107,7 @@ STATIC struct var *vartab[VTABSIZE];
STATIC struct var **hashvar(const char *);
STATIC int vpcmp(const void *, const void *);
-STATIC struct var **findvar(struct var **, const char *);
+STATIC struct var **findvar(const char *);
/*
* Initialize the varable symbol tables and import the environment
@@ -247,9 +247,8 @@ struct var *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) {
@@ -311,7 +310,7 @@ lookupvar(const char *name)
{
struct var *v;
- if ((v = *findvar(hashvar(name), name)) && !(v->flags & VUNSET)) {
+ if ((v = *findvar(name)) && !(v->flags & VUNSET)) {
#ifdef WITH_LINENO
if (v == &vlineno && v->text == linenovar) {
fmtstr(linenovar+7, sizeof(linenovar)-7, "%d", lineno);
@@ -418,7 +417,7 @@ exportcmd(int argc, char **argv)
if ((p = strchr(name, '=')) != NULL) {
p++;
} else {
- if ((vp = *findvar(hashvar(name), name))) {
+ if ((vp = *findvar(name))) {
vp->flags |= flag;
continue;
}
@@ -462,7 +461,6 @@ localcmd(int argc, char **argv)
void mklocal(char *name, int flags)
{
struct localvar *lvp;
- struct var **vpp;
struct var *vp;
INTOFF;
@@ -475,8 +473,7 @@ void mklocal(char *name, int flags)
} else {
char *eq;
- vpp = hashvar(name);
- vp = *findvar(vpp, name);
+ vp = *findvar(name);
eq = strchr(name, '=');
if (vp == NULL) {
if (eq)
@@ -663,9 +660,11 @@ vpcmp(const void *a, const void *b)
}
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 (varequal((*vpp)->text, name)) {
break;
}
--
2.35.3
next reply other threads:[~2022-05-10 8:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-10 8:16 Ron Yorston [this message]
2024-04-05 10:46 ` [PATCH] var: move hashvar() calls into findvar() Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=627a1f77.3CLq0J9mI6V6UePB%rmy@frippery.org \
--to=rmy@frippery.org \
--cc=dash@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).