[PATCH] Small speed improvement to eval, from Sebastian Freundt

Aidan Kehoe kehoea at parhasard.net
Thu May 24 03:34:18 EDT 2007




src/ChangeLog addition:

2007-05-24  Aidan Kehoe  <kehoea at parhasard.net>

	* eval.c (Feval):
	Small optimisations from Sebastian Freundt's SXEmacs work; don't
	do the unnecessary book-keeping in the trivial cases, only look
	for an indirect function if the stored function is a bound
	symbol. 


XEmacs Trunk source patch:
Diff command:   cvs -q diff -Nu
Files affected: src/eval.c
===================================================================
RCS

Index: src/eval.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/eval.c,v
retrieving revision 1.95
diff -u -u -r1.95 eval.c
--- src/eval.c	2007/02/22 16:53:26	1.95
+++ src/eval.c	2007/05/24 07:27:15
@@ -3539,6 +3539,16 @@
   check_proper_critical_section_lisp_protection ();
 #endif
 
+  if (!CONSP (form))
+    {
+      if (SYMBOLP (form))
+        {
+          return Fsymbol_value (form);
+        }
+
+      return form;
+    }
+
   /* I think this is a pretty safe place to call Lisp code, don't you? */
   while (!in_warnings && !NILP (Vpending_warnings)
 	 /* well, perhaps not so safe after all! */
@@ -3571,14 +3581,6 @@
       unbind_to (speccount);
     }
 
-  if (!CONSP (form))
-    {
-      if (SYMBOLP (form))
-	return Fsymbol_value (form);
-      else
-	return form;
-    }
-
   QUIT;
   if (need_to_garbage_collect)
     {
@@ -3622,7 +3624,13 @@
   /* At this point, only original_fun and original_args
      have values that will be used below. */
  retry:
-  fun = indirect_function (original_fun, 1);
+  /* Optimise for no indirection.  */
+  fun = original_fun;
+  if (SYMBOLP (fun) && !EQ (fun, Qunbound)
+      && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
+    {
+      fun = indirect_function(original_fun, 1);
+    }
 
   if (SUBRP (fun))
     {

-- 
On the quay of the little Black Sea port, where the rescued pair came once
more into contact with civilization, Dobrinton was bitten by a dog which was
assumed to be mad, though it may only have been indiscriminating. (Saki)



More information about the XEmacs-Patches mailing list