unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] src/eval.c (Fapply): Remove unnecessary goto
@ 2014-11-25  3:21 Lee Duhem
  2014-12-04 19:18 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Lee Duhem @ 2014-11-25  3:21 UTC (permalink / raw)
  To: Emacs Devel

---
 src/ChangeLog |  4 ++++
 src/eval.c    | 12 ++++--------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 448de36..663ca9e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2014-11-25  Lee Duhem  <lee.duhem@gmail.com>
+
+ * eval.c (Fapply): Remove unnecessary goto.
+
 2014-11-24  Lars Magne Ingebrigtsen  <larsi@gnus.org>

  * gnutls.c: Fix compilation warnings given fix --enable-gcc-warnings.
diff --git a/src/eval.c b/src/eval.c
index 77b1db9..45e5389 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2298,19 +2298,15 @@ usage: (apply FUNCTION &rest ARGUMENTS)  */)
   if (SYMBOLP (fun) && !NILP (fun)
       && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
     fun = indirect_function (fun);
+
   if (NILP (fun))
     {
       /* Let funcall get the error.  */
       fun = args[0];
-      goto funcall;
     }
-
-  if (SUBRP (fun))
+  else if (SUBRP (fun))
     {
-      if (numargs < XSUBR (fun)->min_args
-  || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs))
- goto funcall; /* Let funcall get the error.  */
-      else if (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args > numargs)
+      if (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args > numargs)
  {
   /* Avoid making funcall cons up a yet another new vector of arguments
      by explicitly supplying nil's for optional values.  */
@@ -2320,7 +2316,7 @@ usage: (apply FUNCTION &rest ARGUMENTS)  */)
   funcall_nargs = 1 + XSUBR (fun)->max_args;
  }
     }
- funcall:
+
   /* We add 1 to numargs because funcall_args includes the
      function itself as well as its arguments.  */
   if (!funcall_args)
-- 
1.9.3



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

* Re: [PATCH] src/eval.c (Fapply): Remove unnecessary goto
  2014-11-25  3:21 [PATCH] src/eval.c (Fapply): Remove unnecessary goto Lee Duhem
@ 2014-12-04 19:18 ` Stefan Monnier
  2014-12-05  8:17   ` Lee Duhem
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2014-12-04 19:18 UTC (permalink / raw)
  To: Lee Duhem; +Cc: Emacs Devel

> @@ -1532,8 +1532,7 @@ See also the function `condition-case'.  */)
>    || NILP (clause)
>    /* A `debug' symbol in the handler list disables the normal
>       suppression of the debugger.  */
> -  || (CONSP (clause) && CONSP (clause)
> -      && !NILP (Fmemq (Qdebug, clause)))
> +  || (CONSP (clause) && !NILP (Fmemq (Qdebug, clause)))
>    /* Special handler that means "print a message and run debugger
>       if requested".  */
>    || EQ (h->tag_or_ch, Qerror)))

Oops, indeed.  Installed in emacs-24.

> + * eval.c (Fapply): Remove unnecessary goto.

Yes, that function was poorly structured.  I had some restructuring in
my local tree as well for a long time, so I took advantage of your patch
to do a more thorough job (installed in master).

> -      if (numargs < XSUBR (fun)->min_args
> -  || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs))
> - goto funcall; /* Let funcall get the error.  */
> -      else if (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args > numargs)
> +      if (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args > numargs)

This is actually not quite right: you fail to test

   numargs < XSUBR (fun)->min_args

which means that you can end up adding args which are truly missing
(i.e. not optional).

> + * eval.c(Fbacktrace): Avoid unnecessary strlen calls.

I'm ambivalent on this one: printing the backtrace really shouldn't be
performance sensitive, and using -1 makes it easier to change the code.


        Stefan



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

* Re: [PATCH] src/eval.c (Fapply): Remove unnecessary goto
  2014-12-04 19:18 ` Stefan Monnier
@ 2014-12-05  8:17   ` Lee Duhem
  2014-12-05 14:53     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Lee Duhem @ 2014-12-05  8:17 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs Devel

Hi Stefan,

Thank you for your comments.

On Fri, Dec 5, 2014 at 3:18 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> Oops, indeed.  Installed in emacs-24.

Why do not change the master branch?

Let me guess. Because this is a bug fix, so it should come to
current release branch, aka emacs-24, and master branch will
get this change when emacs-24 is merged to it. Am I correct?

>
>> + * eval.c (Fapply): Remove unnecessary goto.
>
> Yes, that function was poorly structured.  I had some restructuring in
> my local tree as well for a long time, so I took advantage of your patch
> to do a more thorough job (installed in master).
>
>> -      if (numargs < XSUBR (fun)->min_args
>> -  || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs))
>> - goto funcall; /* Let funcall get the error.  */
>> -      else if (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args > numargs)
>> +      if (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args > numargs)
>
> This is actually not quite right:

Now I see. I missed a possible error condition.

>
>> + * eval.c(Fbacktrace): Avoid unnecessary strlen calls.
>
> I'm ambivalent on this one: printing the backtrace really shouldn't be
> performance sensitive, and using -1 makes it easier to change the code.

Good point.

Sincerely,
lee



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

* Re: [PATCH] src/eval.c (Fapply): Remove unnecessary goto
  2014-12-05  8:17   ` Lee Duhem
@ 2014-12-05 14:53     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2014-12-05 14:53 UTC (permalink / raw)
  To: Lee Duhem; +Cc: Emacs Devel

> Let me guess.  Because this is a bug fix, so it should come to
> current release branch, aka emacs-24, and master branch will
> get this change when emacs-24 is merged to it.  Am I correct?

That's right.


        Stefan



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

end of thread, other threads:[~2014-12-05 14:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-25  3:21 [PATCH] src/eval.c (Fapply): Remove unnecessary goto Lee Duhem
2014-12-04 19:18 ` Stefan Monnier
2014-12-05  8:17   ` Lee Duhem
2014-12-05 14:53     ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

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

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 read-only IMAP folder(s) and NNTP newsgroup(s).