From c4cc13917cdf733b142ed2dee9b5aee9df9f8153 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Tue, 1 Sep 2020 21:28:22 +0200 Subject: [PATCH] * lisp/emacs-lisp/cl-macs.el (cl-the): Emit compiler hints when native. --- lisp/emacs-lisp/cl-macs.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index c38019d4a73..7adb9100703 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -2329,6 +2329,14 @@ values. For compatibility, (cl-values A B C) is a synonym for (list A B C). (defmacro cl-the (type form) "Return FORM. If type-checking is enabled, assert that it is of TYPE." (declare (indent 1) (debug (cl-type-spec form))) + ;; When native compiling possibly add the appropriate type hint. + (when (and (boundp 'byte-native-compiling) + byte-native-compiling) + (setf form + (cl-case type + (fixnum `(comp-hint-fixnum ,form)) + (cons `(comp-hint-cons ,form)) + (otherwise form)))) (if (not (or (not (cl--compiling-file)) (< cl--optimize-speed 3) (= cl--optimize-safety 3))) -- 2.39.5