emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Simplify more functions by removing local variables


From: Chris Gregory
Subject: Simplify more functions by removing local variables
Date: Wed, 28 Dec 2016 01:41:23 -0600

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)));
 }
 
 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 via email to

[Prev in Thread] Current Thread [Next in Thread]