From: Andrea Corallo Date: Mon, 14 Sep 2020 19:06:54 +0000 (+0200) Subject: * Add 'cl-optimize' as function declaration X-Git-Tag: emacs-28.0.90~2727^2~442 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=95312717c726e390de26bd85341a17b163b40fd7;p=emacs.git * Add 'cl-optimize' as function declaration * lisp/emacs-lisp/cl-macs.el: Register cl-optimize into `defun-declarations-alist' and `macro-declarations-alist'. (cl--optimize): New function to serve 'cl-optimize' declaration. --- diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 7adb9100703..2730e8f24a3 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -2347,6 +2347,26 @@ values. For compatibility, (cl-values A B C) is a synonym for (list A B C). (list ',type ,temp ',form))) ,temp)))) +;;;###autoload +(or (assq 'cl-optimize defun-declarations-alist) + (let ((x (list 'cl-optimize #'cl--optimize))) + (push x macro-declarations-alist) + (push x defun-declarations-alist))) + +(defun cl--optimize (f _args &rest qualities) + "Serve 'cl-optimize' in function declarations. +Example: +(defun foo (x) + (declare (cl-optimize (speed 3) (safety 0))) + x)" + (cl-loop for (qly val) in qualities + do (cl-ecase qly + (speed + (setf cl--optimize-speed val) + (byte-run--set-speed f nil val)) + (safety + (setf cl--optimize-safety val))))) + (defvar cl--proclaim-history t) ; for future compilers (defvar cl--declare-stack t) ; for future compilers