diff options
| author | Mattias EngdegÄrd | 2022-12-16 11:08:02 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2022-12-16 17:17:23 +0100 |
| commit | 17d65c99cd812e085d85f790c83ec0d540490a55 (patch) | |
| tree | 21bce18eca8f858d3163cc9bcc677543903669a5 | |
| parent | b01d0246d71a7a3fd92b2864a3c0c0bc9367ee0b (diff) | |
| download | emacs-17d65c99cd812e085d85f790c83ec0d540490a55.tar.gz emacs-17d65c99cd812e085d85f790c83ec0d540490a55.zip | |
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.
| -rw-r--r-- | lisp/emacs-lisp/gv.el | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index 11251d7a963..48bc0269f36 100644 --- 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. | |||
| 417 | (lambda (do key alist &optional default remove testfn) | 417 | (lambda (do key alist &optional default remove testfn) |
| 418 | (macroexp-let2 macroexp-copyable-p k key | 418 | (macroexp-let2 macroexp-copyable-p k key |
| 419 | (gv-letplace (getter setter) alist | 419 | (gv-letplace (getter setter) alist |
| 420 | (macroexp-let2 nil p `(if (and ,testfn (not (eq ,testfn 'eq))) | 420 | (macroexp-let2 nil p (if (member testfn '(nil 'eq #'eq)) |
| 421 | (assoc ,k ,getter ,testfn) | 421 | `(assq ,k ,getter) |
| 422 | (assq ,k ,getter)) | 422 | `(assoc ,k ,getter ,testfn)) |
| 423 | (funcall do (if (null default) `(cdr ,p) | 423 | (funcall do (if (null default) `(cdr ,p) |
| 424 | `(if ,p (cdr ,p) ,default)) | 424 | `(if ,p (cdr ,p) ,default)) |
| 425 | (lambda (v) | 425 | (lambda (v) |