all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chris Gregory <czipperz@gmail.com>
To: emacs-devel@gnu.org
Subject: Simplify more functions by removing local variables
Date: Wed, 28 Dec 2016 01:41:23 -0600	[thread overview]
Message-ID: <87zijgjyak.fsf@gmail.com> (raw)

Many functions do something like

> type var;
> var = x;
> use (var);

and then never use var again.  I simplified these to

> use(x);

while not reordering instructions.  The following would be unchanged:

> type var;
> var = f ();
> g ();
> h (var);

-- 
Chris Gregory

diff --git a/src/eval.c b/src/eval.c
index e50e26a..1def5db 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1179,12 +1179,10 @@ If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.
 usage: (unwind-protect BODYFORM UNWINDFORMS...)  */)
   (Lisp_Object args)
 {
-  Lisp_Object val;
   ptrdiff_t count = SPECPDL_INDEX ();
 
   record_unwind_protect (prog_ignore, XCDR (args));
-  val = eval_sub (XCAR (args));
-  return unbind_to (count, val);
+  return unbind_to (count, eval_sub (XCAR (args)));
 }
 \f
 DEFUN ("condition-case", Fcondition_case, Scondition_case, 2, UNEVALLED, 0,
@@ -1502,7 +1500,6 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit)
      and DATA is (REAL-ERROR-SYMBOL . REAL-DATA).
      That is a special case--don't do this in other situations.  */
   Lisp_Object conditions;
-  Lisp_Object string;
   Lisp_Object real_error_symbol
     = (NILP (error_symbol) ? Fcar (data) : error_symbol);
   register Lisp_Object clause = Qnil;
@@ -1570,37 +1567,26 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit)
 	  || (CONSP (clause) && !NILP (Fmemq (Qdebug, clause)))
 	  /* Special handler that means "print a message and run debugger
 	     if requested".  */
-	  || EQ (h->tag_or_ch, Qerror)))
-    {
-      bool debugger_called
-	= maybe_call_debugger (conditions, error_symbol, data);
+	  || EQ (h->tag_or_ch, Qerror))
+      && maybe_call_debugger (conditions, error_symbol, data)
       /* We can't return values to code which signaled an error, but we
 	 can continue code which has signaled a quit.  */
-      if (keyboard_quit && debugger_called && EQ (real_error_symbol, Qquit))
-	return Qnil;
-    }
+      && keyboard_quit
+      && EQ (real_error_symbol, Qquit))
+    return Qnil;
 
   if (!NILP (clause))
-    {
-      Lisp_Object unwind_data
-	= (NILP (error_symbol) ? data : Fcons (error_symbol, data));
-
-      unwind_to_catch (h, unwind_data);
-    }
-  else
-    {
-      if (handlerlist != handlerlist_sentinel)
-	/* FIXME: This will come right back here if there's no `top-level'
-	   catcher.  A better solution would be to abort here, and instead
-	   add a catch-all condition handler so we never come here.  */
-	Fthrow (Qtop_level, Qt);
-    }
+    unwind_to_catch (h, NILP (error_symbol) ? data : Fcons (error_symbol, data));
+  else if (handlerlist != handlerlist_sentinel)
+    /* FIXME: This will come right back here if there's no `top-level'
+       catcher.  A better solution would be to abort here, and instead
+       add a catch-all condition handler so we never come here.  */
+    Fthrow (Qtop_level, Qt);
 
   if (! NILP (error_symbol))
     data = Fcons (error_symbol, data);
 
-  string = Ferror_message_string (data);
-  fatal ("%s", SDATA (string));
+  fatal ("%s", SDATA (Ferror_message_string (data)));
 }
 
 /* Like xsignal, but takes 0, 1, 2, or 3 args instead of a list.  */
@@ -1835,9 +1821,7 @@ then strings and vectors are not accepted.  */)
   register Lisp_Object funcar;
   Lisp_Object if_prop = Qnil;
 
-  fun = function;
-
-  fun = indirect_function (fun); /* Check cycles.  */
+  fun = indirect_function (function); /* Check cycles.  */
   if (NILP (fun))
     return Qnil;
 



                 reply	other threads:[~2016-12-28  7:41 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=87zijgjyak.fsf@gmail.com \
    --to=czipperz@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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 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.