summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorKarl Heuer <kwzh@gnu.org>1997-11-03 03:58:23 +0000
committerKarl Heuer <kwzh@gnu.org>1997-11-03 03:58:23 +0000
commit79d137ffe7dac5fe3041b4916c715f4ce91143af (patch)
tree502063a7fa0b365af60dc2f20b485604b316d997 /lisp/emacs-lisp
parentd5824b35e443e25a9ed06af9d3f97b1d3e5463e2 (diff)
downloademacs-79d137ffe7dac5fe3041b4916c715f4ce91143af.tar.gz
emacs-79d137ffe7dac5fe3041b4916c715f4ce91143af.tar.bz2
emacs-79d137ffe7dac5fe3041b4916c715f4ce91143af.zip
(byte-optimize-concat): New function.
Diffstat (limited to 'lisp/emacs-lisp')
-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 @@
((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)
@@ -1076,6 +1076,18 @@
(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)))
;;; enumerating those functions which need not be called if the returned
;;; value is not used. That is, something like