From: Nikodemus Siivola Date: Fri, 8 Feb 2008 14:16:11 +0000 (+0000) Subject: 1.0.14.26: tweak COND slightly X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=3975b8496884b7f3672ef6772a957123568466d1;p=sbcl.git 1.0.14.26: tweak COND slightly * Don't expand into a final (COND), but directly to NIL (easier to read macroexpansion.) * Check for the common case of final T, so that the last clause can be unconditional instead of generating redundant IF. --- diff --git a/src/code/defboot.lisp b/src/code/defboot.lisp index bce8766..16fd031 100644 --- a/src/code/defboot.lisp +++ b/src/code/defboot.lisp @@ -69,7 +69,8 @@ (defmacro-mundanely cond (&rest clauses) (if (endp clauses) nil - (let ((clause (first clauses))) + (let ((clause (first clauses)) + (more (rest clauses))) (if (atom clause) (error "COND clause is not a list: ~S" clause) (let ((test (first clause)) @@ -79,10 +80,12 @@ `(let ((,n-result ,test)) (if ,n-result ,n-result - (cond ,@(rest clauses))))) - `(if ,test - (progn ,@forms) - (cond ,@(rest clauses))))))))) + (cond ,@more)))) + (if (eq t test) + `(progn ,@forms) + `(if ,test + (progn ,@forms) + ,(when more `(cond ,@more)))))))))) (defmacro-mundanely when (test &body forms) #!+sb-doc diff --git a/tests/walk.impure.lisp b/tests/walk.impure.lisp index 9c3e44b..2045fa0 100644 --- a/tests/walk.impure.lisp +++ b/tests/walk.impure.lisp @@ -933,14 +933,13 @@ Form: A Context: EVAL Form: (PROGN B) Context: EVAL Form: B Context: EVAL Form: (COND ((FOO BAR) A (FOO A))) Context: EVAL -Form: (IF (FOO BAR) (PROGN A (FOO A)) (COND)) Context: EVAL +Form: (IF (FOO BAR) (PROGN A (FOO A)) NIL) Context: EVAL Form: (FOO BAR) Context: EVAL Form: 'GLOBAL-FOO Context: EVAL Form: (PROGN A (FOO A)) Context: EVAL Form: A Context: EVAL Form: (FOO A) Context: EVAL Form: 'GLOBAL-FOO Context: EVAL -Form: (COND) Context: EVAL Form: NIL Context: EVAL; bound: NIL (COND (A B) ((FOO BAR) A (FOO A)))")) diff --git a/version.lisp-expr b/version.lisp-expr index 2b56830..3a10048 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.14.25" +"1.0.14.26"