zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: parameters again
Date: Thu, 28 Oct 1999 10:27:17 +0200 (MET DST)	[thread overview]
Message-ID: <199910280827.KAA18697@beta.informatik.hu-berlin.de> (raw)


I just thought of an easy way to speed up the often needed ${(k)...}
on the special hashes from the parameter modules. Should have thought
of that before...

This avoids calculating the values if they aren't needed.

Bye
 Sven

diff -u oldsrc/Modules/parameter.c Src/Modules/parameter.c
--- oldsrc/Modules/parameter.c	Thu Oct 28 10:13:10 1999
+++ Src/Modules/parameter.c	Thu Oct 28 10:23:34 1999
@@ -181,7 +181,8 @@
     for (i = 0; i < realparamtab->hsize; i++)
 	for (hn = realparamtab->nodes[i]; hn; hn = hn->next) {
 	    pm.nam = hn->nam;
-	    if (func != scancountparams)
+	    if (func != scancountparams &&
+		(flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)))
 		pm.u.str = paramtypestr((Param) hn);
 	    func((HashNode) &pm, flags);
 	}
@@ -312,7 +313,8 @@
 	for (hn = cmdnamtab->nodes[i]; hn; hn = hn->next) {
 	    pm.nam = hn->nam;
 	    cmd = (Cmdnam) hn;
-	    if (func != scancountparams) {
+	    if (func != scancountparams &&
+		(flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL))) {
 		if (cmd->flags & HASHED)
 		    pm.u.str = cmd->u.cmd;
 		else {
@@ -513,7 +515,8 @@
 	for (hn = shfunctab->nodes[i]; hn; hn = hn->next) {
 	    if (dis ? (hn->flags & DISABLED) : !(hn->flags & DISABLED)) {
 		pm.nam = hn->nam;
-		if (func != scancountparams) {
+		if (func != scancountparams &&
+		    (flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL))) {
 		    if (((Shfunc) hn)->flags & PM_UNDEFINED) {
 			Shfunc shf = (Shfunc) hn;
 			pm.u.str =
@@ -621,7 +624,8 @@
 	for (hn = builtintab->nodes[i]; hn; hn = hn->next) {
 	    if (dis ? (hn->flags & DISABLED) : !(hn->flags & DISABLED)) {
 		pm.nam = hn->nam;
-		if (func != scancountparams) {
+		if (func != scancountparams &&
+		    (flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL))) {
 		    char *t = ((((Builtin) hn)->handlerfunc ||
 				(hn->flags & BINF_PREFIX)) ?
 			       "defined" : "undefined");
@@ -1054,7 +1058,8 @@
     pm.level = 0;
 
     while (he) {
-	if (func != scancountparams) {
+	if (func != scancountparams &&
+	    (flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL))) {
 	    sprintf(buf, "%d", he->histnum);
 	    pm.nam = dupstring(buf);
 	    pm.u.str = dupstring(he->text);
@@ -1175,7 +1180,8 @@
     for (job = 1; job < MAXJOB; job++) {
 	if (jobtab[job].stat && jobtab[job].procs &&
 	    !(jobtab[job].stat & STAT_NOPRINT)) {
-	    if (func != scancountparams) {
+	    if (func != scancountparams &&
+		(flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL))) {
 		sprintf(buf, "%d", job);
 		pm.nam = dupstring(buf);
 		pm.u.str = pmjobtext(job);
@@ -1279,7 +1285,8 @@
     for (job = 1; job < MAXJOB; job++) {
 	if (jobtab[job].stat && jobtab[job].procs &&
 	    !(jobtab[job].stat & STAT_NOPRINT)) {
-	    if (func != scancountparams) {
+	    if (func != scancountparams &&
+		(flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL))) {
 		sprintf(buf, "%d", job);
 		pm.nam = dupstring(buf);
 		pm.u.str = pmjobstate(job);
@@ -1410,7 +1417,8 @@
 	for (hn = nameddirtab->nodes[i]; hn; hn = hn->next) {
 	    if (!((nd = (Nameddir) hn)->flags & ND_USERNAME)) {
 		pm.nam = hn->nam;
-		if (func != scancountparams)
+		if (func != scancountparams &&
+		    (flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)))
 		    pm.u.str = dupstring(nd->dir);
 		func((HashNode) &pm, flags);
 	    }
@@ -1477,7 +1485,8 @@
 	for (hn = nameddirtab->nodes[i]; hn; hn = hn->next) {
 	    if ((nd = (Nameddir) hn)->flags & ND_USERNAME) {
 		pm.nam = hn->nam;
-		if (func != scancountparams)
+		if (func != scancountparams &&
+		    (flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)))
 		    pm.u.str = dupstring(nd->dir);
 		func((HashNode) &pm, flags);
 	    }
@@ -1693,7 +1702,8 @@
 		 (!global && !((al = (Alias) hn)->flags & ALIAS_GLOBAL))) &&
 		(dis ? (al->flags & DISABLED) : !(al->flags & DISABLED))) {
 		pm.nam = hn->nam;
-		if (func != scancountparams)
+		if (func != scancountparams &&
+		    (flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)))
 		    pm.u.str = dupstring(al->text);
 		func((HashNode) &pm, flags);
 	    }
diff -u oldsrc/Zle/zleparameter.c Src/Zle/zleparameter.c
--- oldsrc/Zle/zleparameter.c	Thu Oct 28 10:12:58 1999
+++ Src/Zle/zleparameter.c	Thu Oct 28 10:25:34 1999
@@ -145,7 +145,8 @@
     for (i = 0; i < thingytab->hsize; i++)
 	for (hn = thingytab->nodes[i]; hn; hn = hn->next) {
 	    pm.nam = hn->nam;
-	    if (func != scancountparams)
+	    if (func != scancountparams &&
+		(flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)))
 		pm.u.str = widgetstr(((Thingy) hn)->widget);
 	    func((HashNode) &pm, flags);
 	}

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


                 reply	other threads:[~1999-10-28  8:27 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=199910280827.KAA18697@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).