Mercurial > emacs
diff lisp/emacs-lisp/byte-opt.el @ 83676:27d11c1d4e46
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 857-862)
- Update from CVS
- Merge from emacs--rel--22
- Update from CVS: lisp/emacs-lisp/avl-tree.el: New file.
* emacs--rel--22 (patch 97-100)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 246-247)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-38
author | Miles Bader <miles@gnu.org> |
---|---|
date | Mon, 27 Aug 2007 09:21:49 +0000 |
parents | 92ccd83174e6 |
children | d18b96e2d51f b83d0dadb2a7 |
line wrap: on
line diff
--- a/lisp/emacs-lisp/byte-opt.el Mon Aug 27 08:16:42 2007 +0000 +++ b/lisp/emacs-lisp/byte-opt.el Mon Aug 27 09:21:49 2007 +0000 @@ -31,7 +31,7 @@ ;; "No matter how hard you try, you can't make a racehorse out of a pig. ;; You can, however, make a faster pig." ;; -;; Or, to put it another way, the emacs byte compiler is a VW Bug. This code +;; Or, to put it another way, the Emacs byte compiler is a VW Bug. This code ;; makes it be a VW Bug with fuel injection and a turbocharger... You're ;; still not going to make it go faster than 70 mph, but it might be easier ;; to get it there. @@ -1014,12 +1014,23 @@ form)) (defun byte-optimize-if (form) + ;; (if (progn <insts> <test>) <rest>) ==> (progn <insts> (if <test> <rest>)) ;; (if <true-constant> <then> <else...>) ==> <then> ;; (if <false-constant> <then> <else...>) ==> (progn <else...>) ;; (if <test> nil <else...>) ==> (if (not <test>) (progn <else...>)) ;; (if <test> <then> nil) ==> (if <test> <then>) (let ((clause (nth 1 form))) - (cond ((byte-compile-trueconstp clause) + (cond ((and (eq (car-safe clause) 'progn) + ;; `clause' is a proper list. + (null (cdr (last clause)))) + (if (null (cddr clause)) + ;; A trivial `progn'. + (byte-optimize-if `(if ,(cadr clause) ,@(nthcdr 2 form))) + (nconc (butlast clause) + (list + (byte-optimize-if + `(if ,(car (last clause)) ,@(nthcdr 2 form))))))) + ((byte-compile-trueconstp clause) (nth 2 form)) ((null clause) (if (nthcdr 4 form) @@ -1135,9 +1146,9 @@ (put 'featurep 'byte-optimizer 'byte-optimize-featurep) (defun byte-optimize-featurep (form) - ;; Emacs-21's byte-code doesn't run under XEmacs anyway, so we can - ;; safely optimize away this test. - (if (equal '((quote xemacs)) (cdr-safe form)) + ;; Emacs-21's byte-code doesn't run under XEmacs or SXEmacs anyway, so we + ;; can safely optimize away this test. + (if (member (cdr-safe form) '((quote xemacs) (quote sxemacs))) nil form)) @@ -1326,7 +1337,7 @@ ;; This list contains numbers, which are pc values, ;; before each instruction. (defun byte-decompile-bytecode (bytes constvec) - "Turns BYTECODE into lapcode, referring to CONSTVEC." + "Turn BYTECODE into lapcode, referring to CONSTVEC." (let ((byte-compile-constants nil) (byte-compile-variables nil) (byte-compile-tag-number 0))