mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-01 01:41:01 -08:00
alist-get testfn argument evaluation correction
* lisp/emacs-lisp/gv.el (alist-get): Evaluate TESTFN exactly once (previously up to 3 times). Reduce the macro-expansion to include a call to either assoc or assq, not both; this reduces the generated code size in some cases.
This commit is contained in:
parent
b01d0246d7
commit
17d65c99cd
1 changed files with 3 additions and 3 deletions
|
|
@ -417,9 +417,9 @@ The return value is the last VAL in the list.
|
||||||
(lambda (do key alist &optional default remove testfn)
|
(lambda (do key alist &optional default remove testfn)
|
||||||
(macroexp-let2 macroexp-copyable-p k key
|
(macroexp-let2 macroexp-copyable-p k key
|
||||||
(gv-letplace (getter setter) alist
|
(gv-letplace (getter setter) alist
|
||||||
(macroexp-let2 nil p `(if (and ,testfn (not (eq ,testfn 'eq)))
|
(macroexp-let2 nil p (if (member testfn '(nil 'eq #'eq))
|
||||||
(assoc ,k ,getter ,testfn)
|
`(assq ,k ,getter)
|
||||||
(assq ,k ,getter))
|
`(assoc ,k ,getter ,testfn))
|
||||||
(funcall do (if (null default) `(cdr ,p)
|
(funcall do (if (null default) `(cdr ,p)
|
||||||
`(if ,p (cdr ,p) ,default))
|
`(if ,p (cdr ,p) ,default))
|
||||||
(lambda (v)
|
(lambda (v)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue