feat(lib): add doom-compile-function
To be used in some autoloaded libraries, in case they haven't been byte-compiled and contain especially expensive functions.
This commit is contained in:
parent
a18ea683d2
commit
3fe1641937
1 changed files with 9 additions and 0 deletions
|
@ -241,6 +241,15 @@ TRIGGER-HOOK is a list of quoted hooks and/or sharp-quoted functions."
|
|||
((add-hook hook fn -101)))
|
||||
fn)))
|
||||
|
||||
(defun doom-compile-function (fn &optional level)
|
||||
"Compile FN, and natively, if possible."
|
||||
(if (featurep 'native-compile)
|
||||
(let ((native-comp-speed (or level native-comp-speed)))
|
||||
(unless (subr-native-elisp-p (symbol-function fn))
|
||||
(native-compile fn)))
|
||||
(unless (byte-code-function-p (symbol-function fn))
|
||||
(with-no-warnings (byte-compile fn)))))
|
||||
|
||||
|
||||
;;
|
||||
;;; Sugars
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue