all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Define progn_ignore to run Fprogn and ignore output
@ 2016-12-27  2:14 Chris Gregory
  2016-12-27  6:26 ` Eli Zaretskii
  2016-12-27 15:49 ` Alan Mackenzie
  0 siblings, 2 replies; 8+ messages in thread
From: Chris Gregory @ 2016-12-27  2:14 UTC (permalink / raw)
  To: emacs-devel

This patch defines progn_ignore to do Fprogn but not return a result.
This will minorly speed up all operations using `unwind_body'.  It also
simplifies the code for `Fprog1' without sacrificing performance.

diff --git a/src/eval.c b/src/eval.c
index ddcccc2..7e02838 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -456,10 +456,17 @@ usage: (progn BODY...)  */)
 /* Evaluate BODY sequentially, discarding its value.  Suitable for
    record_unwind_protect.  */
 
+static void
+progn_ignore (Lisp_Object body)
+{
+  while (CONSP (body))
+    eval_sub (XCAR (body));
+}
+
 void
 unwind_body (Lisp_Object body)
 {
-  Fprogn (body);
+  progn_ignore (body);
 }
 
 DEFUN ("prog1", Fprog1, Sprog1, 1, UNEVALLED, 0,
@@ -470,15 +477,8 @@ usage: (prog1 FIRST BODY...)  */)
   (Lisp_Object args)
 {
   Lisp_Object val;
-  Lisp_Object args_left;
-
-  args_left = args;
-  val = args;
-
-  val = eval_sub (XCAR (args_left));
-  while (CONSP (args_left = XCDR (args_left)))
-    eval_sub (XCAR (args_left));
-
+  val = eval_sub (XCAR (args));
+  progn_ignore (XCDR (args));
   return val;
 }



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* Re: Define progn_ignore to run Fprogn and ignore output
@ 2016-12-28  1:30 Chris Gregory
  2016-12-28  6:26 ` Paul Eggert
  0 siblings, 1 reply; 8+ messages in thread
From: Chris Gregory @ 2016-12-28  1:30 UTC (permalink / raw)


Your implementation is not what I intended.  Please add the following
diff.  I also fixed an additional place that still was declaring
unwind_body.

diff --git a/src/eval.c b/src/eval.c
index e50e26a..abd4028 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -458,7 +458,11 @@ usage: (progn BODY...)  */)
 void
 prog_ignore (Lisp_Object body)
 {
-  Fprogn (body);
+  while (CONSP (body))
+    {
+      eval_sub (XCAR (body));
+      body = XCDR (body);
+    }
 }
 
 DEFUN ("prog1", Fprog1, Sprog1, 1, UNEVALLED, 0,
diff --git a/test/manual/etags/c-src/emacs/src/lisp.h b/test/manual/etags/c-src/emacs/src/lisp.h
index db87229..1b9d82b 100644
--- a/test/manual/etags/c-src/emacs/src/lisp.h
+++ b/test/manual/etags/c-src/emacs/src/lisp.h
@@ -4042,7 +4042,7 @@ extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object);
 extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object);
 extern void init_eval (void);
 extern void syms_of_eval (void);
-extern void unwind_body (Lisp_Object);
+extern void prog_ignore (Lisp_Object);
 extern ptrdiff_t record_in_backtrace (Lisp_Object, Lisp_Object *, ptrdiff_t);
 extern void mark_specpdl (void);
 extern void get_backtrace (Lisp_Object array);



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-12-28  6:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-27  2:14 Define progn_ignore to run Fprogn and ignore output Chris Gregory
2016-12-27  6:26 ` Eli Zaretskii
2016-12-27 16:28   ` Chris Gregory
2016-12-27 18:45     ` Paul Eggert
2016-12-27 15:49 ` Alan Mackenzie
2016-12-27 16:28   ` Chris Gregory
  -- strict thread matches above, loose matches on Subject: below --
2016-12-28  1:30 Chris Gregory
2016-12-28  6:26 ` Paul Eggert

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.