projects
/
emacs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b01d024
)
alist-get testfn argument evaluation correction
author
Mattias Engdegård
<mattiase@acm.org>
Fri, 16 Dec 2022 10:08:02 +0000
(11:08 +0100)
committer
Mattias Engdegård
<mattiase@acm.org>
Fri, 16 Dec 2022 16:17:23 +0000
(17:17 +0100)
* 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.
lisp/emacs-lisp/gv.el
patch
|
blob
|
history
diff --git
a/lisp/emacs-lisp/gv.el
b/lisp/emacs-lisp/gv.el
index 11251d7a963091e57a535ae42d748225f8afe939..48bc0269f36e42a66b87fcafe45998a3e674662a 100644
(file)
--- a/
lisp/emacs-lisp/gv.el
+++ b/
lisp/emacs-lisp/gv.el
@@
-417,9
+417,9
@@
The return value is the last VAL in the list.
(lambda (do key alist &optional default remove testfn)
(macroexp-let2 macroexp-copyable-p k key
(gv-letplace (getter setter) alist
- (macroexp-let2 nil p
`(if (and ,testfn (not (eq ,testfn 'eq)
))
-
(assoc ,k ,getter ,testfn
)
-
(assq ,k ,getter
))
+ (macroexp-let2 nil p
(if (member testfn '(nil 'eq #'eq
))
+
`(assq ,k ,getter
)
+
`(assoc ,k ,getter ,testfn
))
(funcall do (if (null default) `(cdr ,p)
`(if ,p (cdr ,p) ,default))
(lambda (v)