changeset 3989:53260b0cd16b

[xemacs-hg @ 2007-05-26 19:00:16 by aidan] Small speed improvement to eval, from Sebastian Freundt.
author aidan
date Sat, 26 May 2007 19:00:20 +0000
parents 1227374e7199
children 126e9854d9f5
files src/ChangeLog src/eval.c
diffstat 2 files changed, 25 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sat May 26 18:28:23 2007 +0000
+++ b/src/ChangeLog	Sat May 26 19:00:20 2007 +0000
@@ -1,3 +1,11 @@
+2007-05-24  Aidan Kehoe  <kehoea@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. 
+
 2007-05-24  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* free-hook.c (check_free):
--- a/src/eval.c	Sat May 26 18:28:23 2007 +0000
+++ b/src/eval.c	Sat May 26 19:00:20 2007 +0000
@@ -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))
     {