emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master eb6bbd9: Use memql instead of memq in pcase


From: Mattias Engdegård
Subject: [Emacs-diffs] master eb6bbd9: Use memql instead of memq in pcase
Date: Thu, 28 Mar 2019 18:57:49 -0400 (EDT)

branch: master
commit eb6bbd9fb175cacdfdc54c1187f5785ed3858f2f
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    Use memql instead of memq in pcase
    
    * lisp/emacs-lisp/pcase.el (pcase--u1):
    Use memql instead of memq to work with bignums (Bug#34781).
    * test/lisp/emacs-lisp/pcase-tests.el (pcase-tests-member): Test the above.
---
 lisp/emacs-lisp/pcase.el            | 8 ++++----
 test/lisp/emacs-lisp/pcase-tests.el | 4 +++-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index 9de2401..a644453 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -785,7 +785,7 @@ Otherwise, it defers to REST which is a list of branches of 
the form
    ((eq 'or (caar matches))
     (let* ((alts (cdar matches))
            (var (if (eq (caar alts) 'match) (cadr (car alts))))
-           (simples '()) (others '()) (memq-ok t))
+           (simples '()) (others '()) (memql-ok t))
       (when var
         (dolist (alt alts)
           (if (and (eq (car alt) 'match) (eq var (cadr alt))
@@ -793,16 +793,16 @@ Otherwise, it defers to REST which is a list of branches 
of the form
                      (eq (car-safe upat) 'quote)))
               (let ((val (cadr (cddr alt))))
                 (unless (or (integerp val) (symbolp val))
-                  (setq memq-ok nil))
+                  (setq memql-ok nil))
                 (push (cadr (cddr alt)) simples))
             (push alt others))))
       (cond
        ((null alts) (error "Please avoid it") (pcase--u rest))
-       ;; Yes, we can use `memq' (or `member')!
+       ;; Yes, we can use `memql' (or `member')!
        ((> (length simples) 1)
         (pcase--u1 (cons `(match ,var
                                  . (pred (pcase--flip
-                                          ,(if memq-ok #'memq #'member)
+                                          ,(if memql-ok #'memql #'member)
                                           ',simples)))
                          (cdr matches))
                    code vars
diff --git a/test/lisp/emacs-lisp/pcase-tests.el 
b/test/lisp/emacs-lisp/pcase-tests.el
index 1e9d37f..af8c9a3 100644
--- a/test/lisp/emacs-lisp/pcase-tests.el
+++ b/test/lisp/emacs-lisp/pcase-tests.el
@@ -51,11 +51,13 @@
 
 (ert-deftest pcase-tests-member ()
   (should (pcase-tests-grep
-           'memq (macroexpand-all '(pcase x ((or 1 2 3) body)))))
+           'memql (macroexpand-all '(pcase x ((or 1 2 3) body)))))
   (should (pcase-tests-grep
            'member (macroexpand-all '(pcase x ((or "a" 2 3) body)))))
   (should-not (pcase-tests-grep
                'memq (macroexpand-all '(pcase x ((or "a" 2 3) body)))))
+  (should-not (pcase-tests-grep
+               'memql (macroexpand-all '(pcase x ((or "a" 2 3) body)))))
   (let ((exp (macroexpand-all
                       '(pcase x
                          ("a" body1)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]