c_leta: don't compute whole list length for optimization
authorDaniel Kochmański <daniel@turtleware.eu>
Sun, 16 Aug 2015 16:28:49 +0000 (18:28 +0200)
committerDaniel Kochmański <daniel@turtleware.eu>
Sun, 16 Aug 2015 16:28:49 +0000 (18:28 +0200)
This is interpreter performance tweak. Behavior stays the same.

Signed-off-by: Daniel Kochmański <daniel@turtleware.eu>
src/c/compiler.d

index ff76d89..31c3d91 100644 (file)
@@ -1551,10 +1551,10 @@ c_let_leta(cl_env_ptr env, int op, cl_object args, int flags) {
         specials = env->values[3];
 
         /* Optimize some common cases */
-        switch(ecl_length(bindings)) {
-        case 0:         return c_locally(env, CDR(args), flags);
-        case 1:         op = OP_BIND; break;
-        }
+        if (bindings == ECL_NIL)
+                return c_locally(env, CDR(args), flags);
+        if (ECL_CONS_CDR(bindings) == ECL_NIL)
+                op = OP_BIND;
 
         for (vars=ECL_NIL, l=bindings; !Null(l); ) {
                 cl_object aux = pop(&l);