mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 09:14:18 +00:00
* lisp/emacs-lisp/pcase.el (pcase--macroexpand): Normalise atom etc.
Transform (pred P) for P in {atom, nlistp, identity, not} into
predicates that pcase already understands in type terms.
This doesn't affect the behaviour but generates better code.
This commit is contained in:
parent
cd8c85c4fd
commit
3b547e4f5d
1 changed files with 11 additions and 1 deletions
|
|
@ -523,7 +523,17 @@ how many time this CODEGEN is called."
|
|||
(cond
|
||||
((null head)
|
||||
(if (pcase--self-quoting-p pat) `',pat pat))
|
||||
((memq head '(pred guard quote)) pat)
|
||||
((memq head '(guard quote)) pat)
|
||||
((eq head 'pred)
|
||||
;; Ad-hoc expansion of some predicates that are the complement of another.
|
||||
;; Not required for correctness but results in better code.
|
||||
(let* ((expr (cadr pat))
|
||||
(compl (assq expr '((atom . consp)
|
||||
(nlistp . listp)
|
||||
(identity . null)))))
|
||||
(cond (compl `(,head (not ,(cdr compl))))
|
||||
((eq expr 'not) `(,head null)) ; normalise
|
||||
(t pat))))
|
||||
((memq head '(or and)) `(,head ,@(mapcar #'pcase--macroexpand (cdr pat))))
|
||||
((eq head 'app) `(app ,(nth 1 pat) ,(pcase--macroexpand (nth 2 pat))))
|
||||
(t
|
||||
|
|
|
|||
Loading…
Reference in a new issue