summaryrefslogtreecommitdiff
path: root/Src/params.c
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2006-03-06 15:38:59 +0000
committerBart Schaefer <barts@users.sourceforge.net>2006-03-06 15:38:59 +0000
commit20aae107b8e662a1a484eb7b22fe3155a3a92c7b (patch)
tree947658cc5bff668b16306b805faa9f48e8488bb3 /Src/params.c
parente43a5fc8ea0725501c6d743df4432cd8879d943b (diff)
downloadzsh-20aae107b8e662a1a484eb7b22fe3155a3a92c7b.tar.gz
zsh-20aae107b8e662a1a484eb7b22fe3155a3a92c7b.zip
22321: optimize 22318.
Diffstat (limited to 'Src/params.c')
-rw-r--r--Src/params.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/Src/params.c b/Src/params.c
index efdb42aca..135c40f1d 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2820,11 +2820,11 @@ tiedarrsetfn(Param pm, char *x)
*dptr->arrptr = sepsplit(x, sepbuf, 0, 0);
if (pm->flags & PM_UNIQUE)
uniqarray(*dptr->arrptr);
+ zsfree(x);
} else
*dptr->arrptr = NULL;
if (pm->ename)
arrfixenv(pm->nam, *dptr->arrptr);
- zsfree(x);
}
/**/
@@ -2847,17 +2847,16 @@ tiedarrunsetfn(Param pm, UNUSED(int exp))
}
/**/
-void
-uniqarray(char **x)
+static void
+arrayuniq(char **x, int freeok)
{
char **t, **p = x;
- if (!x || !*x)
- return;
while (*++p)
for (t = x; t < p; t++)
if (!strcmp(*p, *t)) {
- zsfree(*p);
+ if (freeok)
+ zsfree(*p);
for (t = p--; (*t = t[1]) != NULL; t++);
break;
}
@@ -2865,18 +2864,20 @@ uniqarray(char **x)
/**/
void
-zhuniqarray(char **x)
+uniqarray(char **x)
{
- char **t, **p = x;
+ if (!x || !*x)
+ return;
+ arrayuniq(x, !zheapptr(*x));
+}
+/**/
+void
+zhuniqarray(char **x)
+{
if (!x || !*x)
return;
- while (*++p)
- for (t = x; t < p; t++)
- if (!strcmp(*p, *t)) {
- for (t = p--; (*t = t[1]) != NULL; t++);
- break;
- }
+ arrayuniq(x, 0);
}
/* Function to get value of special parameter `#' and `ARGC' */