summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2022-12-19 04:42:18 +0100
committerStefan Kangas <stefankangas@gmail.com>2022-12-19 04:42:18 +0100
commitd468cf91b9fbcd915644246f27dbaa87e23c7e7b (patch)
treec88c14f5372b67e3f02bcb16359b99256d9f2800 /lisp/emacs-lisp
parent9a633dce63904b54738a63eb5007869fd851419a (diff)
parentde2239a584ab9b3bcdea2379f2c54ea3d20d596f (diff)
downloademacs-d468cf91b9fbcd915644246f27dbaa87e23c7e7b.tar.gz
emacs-d468cf91b9fbcd915644246f27dbaa87e23c7e7b.tar.bz2
emacs-d468cf91b9fbcd915644246f27dbaa87e23c7e7b.zip
Merge from origin/emacs-29
de2239a584a Revert "alist-get testfn argument evaluation correction" 856d889f3a8 Revert "Elide broken but unnecessary `if` optimisations" 8e42e20ed7f Revert "Use equal and member instead of eq and memq"
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/byte-opt.el7
-rw-r--r--lisp/emacs-lisp/gv.el6
2 files changed, 8 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 898dfffef63..55b68c58438 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -1298,8 +1298,11 @@ See Info node `(elisp) Integer Basics'."
(if else
`(progn ,condition ,@else)
condition))
- ;; (if X t) -> (not (not X))
- ((and (eq then t) (null else))
+ ;; (if X nil t) -> (not X)
+ ((and (eq then nil) (eq else '(t)))
+ `(not ,condition))
+ ;; (if X t [nil]) -> (not (not X))
+ ((and (eq then t) (or (null else) (eq else '(nil))))
`(not ,(byte-opt--negate condition)))
;; (if VAR VAR X...) -> (or VAR (progn X...))
((and (symbolp condition) (eq condition then))
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index 48bc0269f36..11251d7a963 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.
(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 (member testfn '(nil 'eq #'eq))
- `(assq ,k ,getter)
- `(assoc ,k ,getter ,testfn))
+ (macroexp-let2 nil p `(if (and ,testfn (not (eq ,testfn 'eq)))
+ (assoc ,k ,getter ,testfn)
+ (assq ,k ,getter))
(funcall do (if (null default) `(cdr ,p)
`(if ,p (cdr ,p) ,default))
(lambda (v)