* PATCH: comp_wrapper
@ 2000-02-03 9:40 Sven Wischnowsky
0 siblings, 0 replies; only message in thread
From: Sven Wischnowsky @ 2000-02-03 9:40 UTC (permalink / raw)
To: zsh-workers
The completion function wrapper used to make heap-allocated copies of
the special parameters it ay have to restore. This makes it use
zalloc()ed memory which can then be used directly. In other words: it
makes the wrapper slightly more expensive for functions that make the
special parameters not be restored and makes other functions (the more
common case) a bit cheaper.
Bye
Sven
diff -ru ../z.old/Src/Zle/complete.c Src/Zle/complete.c
--- ../z.old/Src/Zle/complete.c Thu Feb 3 10:37:18 2000
+++ Src/Zle/complete.c Thu Feb 3 10:37:41 2000
@@ -1219,18 +1219,18 @@
orest = comprestore;
comprestore = ztrdup("auto");
ocur = compcurrent;
- opre = dupstring(compprefix);
- osuf = dupstring(compsuffix);
- oipre = dupstring(compiprefix);
- oisuf = dupstring(compisuffix);
- oqipre = dupstring(compqiprefix);
- oqisuf = dupstring(compqisuffix);
- oq = dupstring(compquote);
- oqi = dupstring(compquoting);
- oqs = dupstring(compqstack);
- oaq = dupstring(autoq);
+ opre = ztrdup(compprefix);
+ osuf = ztrdup(compsuffix);
+ oipre = ztrdup(compiprefix);
+ oisuf = ztrdup(compisuffix);
+ oqipre = ztrdup(compqiprefix);
+ oqisuf = ztrdup(compqisuffix);
+ oq = ztrdup(compquote);
+ oqi = ztrdup(compquoting);
+ oqs = ztrdup(compqstack);
+ oaq = ztrdup(autoq);
- HEAPALLOC {
+ PERMALLOC {
owords = arrdup(compwords);
} LASTALLOC;
@@ -1239,38 +1239,48 @@
if (comprestore && !strcmp(comprestore, "auto")) {
compcurrent = ocur;
zsfree(compprefix);
- compprefix = ztrdup(opre);
+ compprefix = opre;
zsfree(compsuffix);
- compsuffix = ztrdup(osuf);
+ compsuffix = osuf;
zsfree(compiprefix);
- compiprefix = ztrdup(oipre);
+ compiprefix = oipre;
zsfree(compisuffix);
- compisuffix = ztrdup(oisuf);
+ compisuffix = oisuf;
zsfree(compqiprefix);
- compqiprefix = ztrdup(oqipre);
+ compqiprefix = oqipre;
zsfree(compqisuffix);
- compqisuffix = ztrdup(oqisuf);
+ compqisuffix = oqisuf;
zsfree(compquote);
- compquote = ztrdup(oq);
+ compquote = oq;
zsfree(compquoting);
- compquoting = ztrdup(oqi);
+ compquoting = oqi;
zsfree(compqstack);
- compqstack = ztrdup(oqs);
+ compqstack = oqs;
zsfree(autoq);
- autoq = ztrdup(oaq);
+ autoq = oaq;
freearray(compwords);
- PERMALLOC {
- compwords = arrdup(owords);
- } LASTALLOC;
+ compwords = owords;
comp_setunset(CP_COMPSTATE |
(~runset & (CP_WORDS | CP_CURRENT | CP_PREFIX |
CP_SUFFIX | CP_IPREFIX | CP_ISUFFIX |
CP_QIPREFIX | CP_QISUFFIX)),
(runset & CP_ALLREALS),
(~kunset & CP_RESTORE), (kunset & CP_ALLKEYS));
- } else
+ } else {
comp_setunset(CP_COMPSTATE, 0, (~kunset & CP_RESTORE),
(kunset & CP_RESTORE));
+ zsfree(opre);
+ zsfree(osuf);
+ zsfree(oipre);
+ zsfree(oisuf);
+ zsfree(oqipre);
+ zsfree(oqisuf);
+ zsfree(oq);
+ zsfree(oqi);
+ zsfree(oqs);
+ zsfree(oaq);
+ freearray(owords);
+ }
zsfree(comprestore);
comprestore = orest;
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2000-02-03 9:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-02-03 9:40 PATCH: comp_wrapper Sven Wischnowsky
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).