aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1997-11-03 03:58:23 +0000
committerKarl Heuer1997-11-03 03:58:23 +0000
commit79d137ffe7dac5fe3041b4916c715f4ce91143af (patch)
tree502063a7fa0b365af60dc2f20b485604b316d997
parentd5824b35e443e25a9ed06af9d3f97b1d3e5463e2 (diff)
downloademacs-79d137ffe7dac5fe3041b4916c715f4ce91143af.tar.gz
emacs-79d137ffe7dac5fe3041b4916c715f4ce91143af.zip
(byte-optimize-concat): New function.
-rw-r--r--lisp/emacs-lisp/byte-opt.el14
1 files changed, 13 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index c75dbe4b696..56dcc9e2427 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -697,7 +697,7 @@
697 ((and (null (nthcdr 3 form)) 697 ((and (null (nthcdr 3 form))
698 (or (memq (nth 1 form) '(1 -1)) 698 (or (memq (nth 1 form) '(1 -1))
699 (memq (nth 2 form) '(1 -1)))) 699 (memq (nth 2 form) '(1 -1))))
700 ;; Optiize (+ x 1) into (1+ x) and (+ x -1) into (1- x). 700 ;; Optimize (+ x 1) into (1+ x) and (+ x -1) into (1- x).
701 (let ((integer 701 (let ((integer
702 (if (memq (nth 1 form) '(1 -1)) 702 (if (memq (nth 1 form) '(1 -1))
703 (nth 1 form) 703 (nth 1 form)
@@ -1076,6 +1076,18 @@
1076 (while (>= (setq count (1- count)) 0) 1076 (while (>= (setq count (1- count)) 0)
1077 (setq form (list 'cdr form))) 1077 (setq form (list 'cdr form)))
1078 form))) 1078 form)))
1079
1080(put 'concat 'byte-optimizer 'byte-optimize-concat)
1081(defun byte-optimize-concat (form)
1082 (let ((args (cdr form))
1083 (constant t))
1084 (while (and args constant)
1085 (or (byte-compile-constp (car args))
1086 (setq constant nil))
1087 (setq args (cdr args)))
1088 (if constant
1089 (eval form)
1090 form)))
1079 1091
1080;;; enumerating those functions which need not be called if the returned 1092;;; enumerating those functions which need not be called if the returned
1081;;; value is not used. That is, something like 1093;;; value is not used. That is, something like