From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: comp_wrapper
Date: Thu, 3 Feb 2000 10:40:42 +0100 (MET) [thread overview]
Message-ID: <200002030940.KAA12822@beta.informatik.hu-berlin.de> (raw)
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
reply other threads:[~2000-02-03 9:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200002030940.KAA12822@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/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.
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).