[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Define progn_ignore to run Fprogn and ignore output
From: |
Alan Mackenzie |
Subject: |
Re: Define progn_ignore to run Fprogn and ignore output |
Date: |
Tue, 27 Dec 2016 15:49:47 +0000 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
Hello, Chris.
Just a small point about your proposed patch.
On Mon, Dec 26, 2016 at 08:14:47PM -0600, Chris Gregory wrote:
> 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));
> +}
> +
Doesn't the above code up an infinite loop? `body' appears not to be
changed between iterations of the while.
> 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;
> }
--
Alan Mackenzie (Nuremberg, Germany).