all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Simplify more functions by removing local variables
@ 2016-12-28  7:41 Chris Gregory
  0 siblings, 0 replies; only message in thread
From: Chris Gregory @ 2016-12-28  7:41 UTC (permalink / raw)
  To: emacs-devel

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;
 



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-12-28  7:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-28  7:41 Simplify more functions by removing local variables Chris Gregory

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.