diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2003-03-25 16:34:00 +0000 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2003-03-25 16:34:00 +0000 |
commit | 66ff2893073b0741ea2a0ccfc58ae585d36be87a (patch) | |
tree | 5f7e1f19666821561f7ae1ff007d4edf82611cd6 /lisp/emacs-lisp | |
parent | 999e64847e279e0b10464311207cc1cb4622dd43 (diff) | |
download | emacs-66ff2893073b0741ea2a0ccfc58ae585d36be87a.tar.gz |
(byte-optimize-set): New. Turn `set' into `setq' when applicable.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/byte-opt.el | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 0bf5a7904c2..7aa34cff6bc 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -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 |