[armedbear-cvs] r13811 - trunk/abcl/src/org/armedbear/lisp

ehuelsmann at common-lisp.net ehuelsmann at common-lisp.net
Thu Jan 26 23:48:19 UTC 2012


Author: ehuelsmann
Date: Thu Jan 26 15:48:18 2012
New Revision: 13811

Log:
Performance improvement: Don't allocate a new environment and
don't snapshot the special bindings on each call to a function with
keyword arguments [which includes compiled functions!].

Modified:
   trunk/abcl/src/org/armedbear/lisp/Closure.java

Modified: trunk/abcl/src/org/armedbear/lisp/Closure.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Closure.java	Wed Jan 25 13:24:06 2012	(r13810)
+++ trunk/abcl/src/org/armedbear/lisp/Closure.java	Thu Jan 26 15:48:18 2012	(r13811)
@@ -656,32 +656,14 @@
       }
   }
 
-  protected final LispObject[] processArgs(LispObject[] args, LispThread thread)
+  
+  private LispObject[] _processArgs(LispObject[] args, LispThread thread,
+          Environment ext) {
+        final LispObject[] array = new LispObject[variables.length];
+        int index = 0;
 
-  {
-    if (optionalParameters.length == 0 && keywordParameters.length == 0)
-      return fastProcessArgs(args);
-    final int argsLength = args.length;
-    if (arity >= 0)
-      {
-        // Fixed arity.
-        if (argsLength != arity)
-          error(new WrongNumberOfArgumentsException(this, arity));
-        return args;
-      }
-    // Not fixed arity.
-    if (argsLength < minArgs)
-      error(new WrongNumberOfArgumentsException(this, minArgs, -1));
-    final LispObject[] array = new LispObject[variables.length];
-    int index = 0;
-    // The bindings established here (if any) are lost when this function
-    // returns. They are used only in the evaluation of initforms for
-    // optional and keyword arguments.
-    final SpecialBindingsMark mark = thread.markSpecialBindings();
-    Environment ext = new Environment(environment);
-    // Section 3.4.4: "...the &environment parameter is bound along with
-    // &whole before any other variables in the lambda list..."
-    try {
+        int argsLength = args.length;
+        
         if (bindInitForms)
           if (envVar != null)
             bindArg(specials, envVar, environment, ext, thread);
@@ -909,11 +891,41 @@
                   error(new WrongNumberOfArgumentsException(this));
               }
           }
+        return array;
+  }
+  
+  protected final LispObject[] processArgs(LispObject[] args, LispThread thread)
+
+  {
+    if (optionalParameters.length == 0 && keywordParameters.length == 0)
+      return fastProcessArgs(args);
+    if (arity >= 0)
+      {
+        // Fixed arity.
+        if (args.length != arity)
+          error(new WrongNumberOfArgumentsException(this, arity));
+        return args;
+      }
+    // Not fixed arity.
+    if (args.length < minArgs)
+      error(new WrongNumberOfArgumentsException(this, minArgs, -1));
+    
+    if (!bindInitForms)
+        return _processArgs(args, thread, environment);
+    
+    // The bindings established here (if any) are lost when this function
+    // returns. They are used only in the evaluation of initforms for
+    // optional and keyword arguments.
+    final SpecialBindingsMark mark = thread.markSpecialBindings();
+    Environment ext = new Environment(environment);
+    // Section 3.4.4: "...the &environment parameter is bound along with
+    // &whole before any other variables in the lambda list..."
+    try {
+        return _processArgs(args, thread, ext);
     }
     finally {
         thread.resetSpecialBindings(mark);
     }
-    return array;
   }
 
   // No optional or keyword parameters.




More information about the armedbear-cvs mailing list