From: Stefan Monnier Date: Tue, 25 Mar 2003 16:34:00 +0000 (+0000) Subject: (byte-optimize-set): New. Turn `set' into `setq' when applicable. X-Git-Tag: ttn-vms-21-2-B4~10753 X-Git-Url: https://code.delx.au/gnu-emacs/commitdiff_plain/66ff2893073b0741ea2a0ccfc58ae585d36be87a (byte-optimize-set): New. Turn `set' into `setq' when applicable. --- diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 0bf5a7904c..7aa34cff6b 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