emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/native-comp 9531271 2/8: * Add 'cl-optimize' as function declara


From: Andrea Corallo
Subject: feature/native-comp 9531271 2/8: * Add 'cl-optimize' as function declaration
Date: Mon, 14 Sep 2020 17:22:56 -0400 (EDT)

branch: feature/native-comp
commit 95312717c726e390de26bd85341a17b163b40fd7
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    * 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 7adb910..2730e8f 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
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]