From 7d4b41b52aeabb6f6f95f9bdfdab96b5fd66909a Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Sat, 23 Sep 2017 19:23:53 +0100
Subject: 41747: Don't create hash entry if just checking existence.
Pass a flag in indicating this case.
---
Src/params.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
(limited to 'Src/params.c')
diff --git a/Src/params.c b/Src/params.c
index c7514de8a..4d4d08085 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -1204,7 +1204,7 @@ isident(char *s)
/**/
static zlong
getarg(char **str, int *inv, Value v, int a2, zlong *w,
- int *prevcharlen, int *nextcharlen)
+ int *prevcharlen, int *nextcharlen, int flags)
{
int hasbeg = 0, word = 0, rev = 0, ind = 0, down = 0, l, i, ishash;
int keymatch = 0, needtok = 0, arglen, len, inpar = 0;
@@ -1407,6 +1407,8 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
if (ishash) {
HashTable ht = v->pm->gsu.h->getfn(v->pm);
if (!ht) {
+ if (flags & SCANPM_CHECKING)
+ return isset(KSHARRAYS) ? 1 : 0;
ht = newparamtable(17, v->pm->node.nam);
v->pm->gsu.h->setfn(v->pm, ht);
}
@@ -1848,7 +1850,8 @@ getindex(char **pptr, Value v, int flags)
zlong we = 0, dummy;
int startprevlen, startnextlen;
- start = getarg(&s, &inv, v, 0, &we, &startprevlen, &startnextlen);
+ start = getarg(&s, &inv, v, 0, &we, &startprevlen, &startnextlen,
+ flags);
if (inv) {
if (!v->isarr && start != 0) {
@@ -1922,7 +1925,7 @@ getindex(char **pptr, Value v, int flags)
if ((com = (*s == ','))) {
s++;
- end = getarg(&s, &inv, v, 1, &dummy, NULL, NULL);
+ end = getarg(&s, &inv, v, 1, &dummy, NULL, NULL, flags);
} else {
end = we ? we : start;
}
--
cgit 1.4.1