Optimize featurep! macro
If we can use doom--current-module and evaluate membership at compile-time, we same a little time, but a fair bit more if we byte-compile.
This commit is contained in:
parent
f6478ab068
commit
0f0f5f6584
1 changed files with 5 additions and 4 deletions
|
@ -367,16 +367,17 @@ Module FLAGs are set in your config's `doom!' block, typically in
|
|||
When this macro is used from inside a module, MODULE and SUBMODULE can be
|
||||
omitted. eg. (featurep! +flag1)"
|
||||
(unless submodule
|
||||
(let* ((path (FILE!))
|
||||
(module-pair (doom-module-from-path path)))
|
||||
(let ((module-pair
|
||||
(or doom--current-module
|
||||
(doom-module-from-path (FILE!)))))
|
||||
(unless module-pair
|
||||
(error "featurep! couldn't detect what module its in! (in %s)" path))
|
||||
(setq flag module
|
||||
module (car module-pair)
|
||||
submodule (cdr module-pair))))
|
||||
(if flag
|
||||
`(and (memq ',flag (doom-module-get ,module ',submodule :flags)) t)
|
||||
`(doom-module-p ,module ',submodule)))
|
||||
(and (memq flag (doom-module-get module submodule :flags)) t)
|
||||
(doom-module-p module submodule)))
|
||||
|
||||
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue