From 95312717c726e390de26bd85341a17b163b40fd7 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Mon, 14 Sep 2020 21:06:54 +0200 Subject: [PATCH] * 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. --- lisp/emacs-lisp/cl-macs.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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 -- 2.39.5