Mercurial > emacs
changeset 50306:2f19a8ed285b
(byte-optimize-set): New. Turn `set' into `setq' when applicable.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 25 Mar 2003 16:34:00 +0000 |
parents | 77bee06b14c5 |
children | 78b51ac98da0 |
files | lisp/emacs-lisp/byte-opt.el |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/emacs-lisp/byte-opt.el Tue Mar 25 16:30:15 2003 +0000 +++ b/lisp/emacs-lisp/byte-opt.el Tue Mar 25 16:34:00 2003 +0000 @@ -1168,6 +1168,18 @@ (if (equal '((quote xemacs)) (cdr-safe form)) nil form)) + +(put 'set 'byte-optimizer 'byte-optimize-set) +(defun byte-optimize-set (form) + (let ((var (car-safe (cdr-safe form)))) + (cond + ((and (eq (car-safe var) 'quote) (consp (cdr var))) + (list* 'setq (cadr var) (cddr form))) + ((and (eq (car-safe var) 'make-local-variable) + (eq (car-safe (setq var (car-safe (cdr var)))) 'quote) + (consp (cdr var))) + `(progn ,(cadr form) (setq ,(cadr var) ,@(cddr form)))) + (t form)))) ;;; enumerating those functions which need not be called if the returned ;;; value is not used. That is, something like