Mercurial > emacs
changeset 20210:622d0b6c6445
(byte-optimize-concat): New function.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Mon, 03 Nov 1997 03:58:23 +0000 |
parents | fd00ceeb06c6 |
children | f722b33c682d |
files | lisp/emacs-lisp/byte-opt.el |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/emacs-lisp/byte-opt.el Mon Nov 03 02:57:05 1997 +0000 +++ b/lisp/emacs-lisp/byte-opt.el Mon Nov 03 03:58:23 1997 +0000 @@ -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