From 66ff2893073b0741ea2a0ccfc58ae585d36be87a Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 25 Mar 2003 16:34:00 +0000 Subject: [PATCH] (byte-optimize-set): New. Turn `set' into `setq' when applicable. --- lisp/emacs-lisp/byte-opt.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 -- 2.39.2