zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: unnecessary calls to getjobtext()
Date: Fri, 14 Jan 2000 11:46:55 +0100 (MET)	[thread overview]
Message-ID: <200001141046.LAA01051@beta.informatik.hu-berlin.de> (raw)


At home I'm currently playing with a word-code version of zsh, this
makes me notice some things...

There are still many unnecessary calls to getjobtext() if I'm not
completely mistaken. We don't need to build the text when we are
executing a function (if that is suspended, the whole function is
suspended and then the text for it will be created) or when we are
sourcing a file (since this can't be suspended as we recently found
out). In both cases: unless the pipe is backgrounded.

Or does anyone see any problems with this? Makes startup and compinit
a bit faster.

Bye
 Sven

diff -ru ../z.old/Src/exec.c Src/exec.c
--- ../z.old/Src/exec.c	Fri Jan 14 09:33:15 2000
+++ Src/exec.c	Fri Jan 14 11:39:22 2000
@@ -1053,7 +1053,7 @@
 	lineno = pline->left->lineno;
 
     if (pline_level == 1) {
-	if (!sfcontext)
+	if ((how & Z_ASYNC) || (!sfcontext && !sourcelevel))
 	    strcpy(list_pipe_text, getjobtext((void *) pline->left));
 	else
 	    list_pipe_text[0] = '\0';
@@ -1639,7 +1639,8 @@
     }
 
     /* Get the text associated with this command. */
-    if (!sfcontext && (jobbing || (how & Z_TIMED)))
+    if ((how & Z_ASYNC) ||
+	(!sfcontext && !sourcelevel && (jobbing || (how & Z_TIMED))))
 	text = getjobtext((void *) cmd);
     else
 	text = NULL;
@@ -2854,7 +2855,7 @@
 {
     LinkList last_file_list = NULL;
     unsigned char *ocs;
-    int ocsp;
+    int ocsp, osfc;
 
     if (errflag)
 	return;
@@ -2882,7 +2883,10 @@
     ocsp = cmdsp;
     cmdstack = (unsigned char *) zalloc(CMDSTACKSZ);
     cmdsp = 0;
+    if ((osfc = sfcontext) == SFC_NONE)
+	sfcontext = SFC_DIRECT;
     doshfunc(shf->nam, shf->funcdef, args, shf->flags, 0);
+    sfcontext = osfc;
     free(cmdstack);
     cmdstack = ocs;
     cmdsp = ocsp;
diff -ru ../z.old/Src/init.c Src/init.c
--- ../z.old/Src/init.c	Fri Jan 14 09:33:16 2000
+++ Src/init.c	Fri Jan 14 09:34:04 2000
@@ -708,7 +708,7 @@
     breaks = loops = 0;
     lastmailcheck = time(NULL);
     locallevel = sourcelevel = 0;
-    sfcontext = SFC_DIRECT;
+    sfcontext = SFC_NONE;
     trapreturn = 0;
     noerrexit = -1;
     nohistsave = 1;
diff -ru ../z.old/Src/zsh.h Src/zsh.h
--- ../z.old/Src/zsh.h	Fri Jan 14 09:33:18 2000
+++ Src/zsh.h	Fri Jan 14 09:33:51 2000
@@ -850,12 +850,13 @@
 
 /* Shell function context types. */
 
-#define SFC_DIRECT   0		/* called directly from the user */
-#define SFC_SIGNAL   1		/* signal handler */
-#define SFC_HOOK     2		/* one of the special functions */
-#define SFC_WIDGET   3		/* user defined widget */
-#define SFC_COMPLETE 4		/* called from completion code */
-#define SFC_CWIDGET  5		/* new style completion widget */
+#define SFC_NONE     0		/* no function running */
+#define SFC_DIRECT   1		/* called directly from the user */
+#define SFC_SIGNAL   2		/* signal handler */
+#define SFC_HOOK     3		/* one of the special functions */
+#define SFC_WIDGET   4		/* user defined widget */
+#define SFC_COMPLETE 5		/* called from completion code */
+#define SFC_CWIDGET  6		/* new style completion widget */
 
 /* node in list of function call wrappers */
 

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


                 reply	other threads:[~2000-01-14 10:47 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=200001141046.LAA01051@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).