]> git.eshelyaron.com Git - emacs.git/commitdiff
(byte-optimize-concat): New function.
authorKarl Heuer <kwzh@gnu.org>
Mon, 3 Nov 1997 03:58:23 +0000 (03:58 +0000)
committerKarl Heuer <kwzh@gnu.org>
Mon, 3 Nov 1997 03:58:23 +0000 (03:58 +0000)
lisp/emacs-lisp/byte-opt.el

index c75dbe4b696b4f9241c74294d5ac532e3cc238e2..56dcc9e24275b387f0c89f2f4f1580a8ec89ea54 100644 (file)
        ((and (null (nthcdr 3 form))
              (or (memq (nth 1 form) '(1 -1))
                  (memq (nth 2 form) '(1 -1))))
-        ;; Optiize (+ x 1) into (1+ x) and (+ x -1) into (1- x).
+        ;; Optimize (+ x 1) into (1+ x) and (+ x -1) into (1- x).
         (let ((integer
                (if (memq (nth 1 form) '(1 -1))
                    (nth 1 form)
       (while (>= (setq count (1- count)) 0)
        (setq form (list 'cdr form)))
       form)))
+
+(put 'concat 'byte-optimizer 'byte-optimize-concat)
+(defun byte-optimize-concat (form)
+  (let ((args (cdr form))
+       (constant t))
+    (while (and args constant)
+      (or (byte-compile-constp (car args))
+         (setq constant nil))
+      (setq args (cdr args)))
+    (if constant
+       (eval form)
+      form)))
 \f
 ;;; enumerating those functions which need not be called if the returned 
 ;;; value is not used.  That is, something like