]> git.eshelyaron.com Git - emacs.git/commitdiff
Revert "Obsolete local set difference functions in favor of seq-difference"
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 29 Sep 2021 15:25:01 +0000 (17:25 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 29 Sep 2021 15:28:02 +0000 (17:28 +0200)
This reverts commit 20f7fa691b7c2859b96550d9ccb326bf394e160d.

gnus-set-difference is orders of magnitude faster than seq-difference
(on these sets), and using seq-difference makes nnimap too
slow.

lisp/emacs-lisp/seq.el
lisp/gnus/gnus-cite.el
lisp/gnus/gnus-range.el
lisp/gnus/gnus-sum.el
lisp/gnus/gnus-uu.el
lisp/gnus/nnimap.el
lisp/gnus/spam.el

index 52c080388b79f1f6da85773f6b26a063a1c956eb..451ff1963163c179392719eb9a5d82d6c1d99f46 100644 (file)
@@ -490,7 +490,6 @@ Equality is defined by TESTFN if non-nil or by `equal' if nil."
               (seq-reverse sequence1)
               '()))
 
-;;;###autoload
 (cl-defgeneric seq-difference (sequence1 sequence2 &optional testfn)
   "Return a list of the elements that appear in SEQUENCE1 but not in SEQUENCE2.
 Equality is defined by TESTFN if non-nil or by `equal' if nil."
index 34947cece89302d50e1af83f3a89d1aa0046f3ce..e9c912109e274e71406b8fa500d706cb01d4bf33 100644 (file)
@@ -839,7 +839,7 @@ See also the documentation for `gnus-article-highlight-citation'."
                 (setq current (car loop)
                       loop (cdr loop))
                 (setcdr current
-                         (seq-difference (cdr current) numbers #'eq)))))))))
+                        (gnus-set-difference (cdr current) numbers)))))))))
 
 (defun gnus-cite-parse-attributions ()
   (let (al-alist)
@@ -999,7 +999,7 @@ See also the documentation for `gnus-article-highlight-citation'."
                    loop (cdr loop))
              (if (eq current best)
                  ()
-                (setcdr current (seq-difference (cdr current) numbers #'eq))
+               (setcdr current (gnus-set-difference (cdr current) numbers))
                (when (null (cdr current))
                  (setq gnus-cite-loose-prefix-alist
                        (delq current gnus-cite-loose-prefix-alist)
index 7d12ae9fdcc0f8b81c5e53a72ea449d2c21d74ed..456209f3d9ada63ed609b77df1491d339946a2f1 100644 (file)
@@ -42,8 +42,13 @@ If RANGE is a single range, return (RANGE).  Otherwise, return RANGE."
 
 (defun gnus-set-difference (list1 list2)
   "Return a list of elements of LIST1 that do not appear in LIST2."
-  (declare (obsolete seq-difference "28.1"))
-  (seq-difference list1 list2 #'eq))
+  (let ((hash2 (make-hash-table :test 'eq))
+        (result nil))
+    (dolist (elt list2) (puthash elt t hash2))
+    (dolist (elt list1)
+      (unless (gethash elt hash2)
+        (setq result (cons elt result))))
+    (nreverse result)))
 
 (defun gnus-range-nconcat (&rest ranges)
   "Return a range comprising all the RANGES, which are pre-sorted.
index b3d0460032de47652f32e7da76da9c8dcb6fa9ee..d790655aa9019019c71868e61d6f8fd7774f7a7f 100644 (file)
@@ -8590,9 +8590,8 @@ If UNREPLIED (the prefix), limit to unreplied articles."
   (interactive "P" gnus-summary-mode)
   (if unreplied
       (gnus-summary-limit
-       (seq-difference gnus-newsgroup-articles
-                       gnus-newsgroup-replied
-                       #'eq))
+       (gnus-set-difference gnus-newsgroup-articles
+       gnus-newsgroup-replied))
     (gnus-summary-limit gnus-newsgroup-replied))
   (gnus-summary-position-point))
 
index f7b761ee339742a0311ee594f6af58efdda75afa..778a8a3ea03da9c3f496fb656dbea137bbc13eb6 100644 (file)
@@ -579,7 +579,7 @@ didn't work, and overwrite existing files.  Otherwise, ask each time."
 (defun gnus-new-processable (unmarkp articles)
   (if unmarkp
       (nreverse (seq-intersection gnus-newsgroup-processable articles #'eq))
-    (seq-difference articles gnus-newsgroup-processable #'eq)))
+    (gnus-set-difference articles gnus-newsgroup-processable)))
 
 (defun gnus-uu-mark-by-regexp (regexp &optional unmark)
   "Set the process mark on articles whose subjects match REGEXP.
index 8a48cd87dba67729133e7accca8604b0f2ea8565..059101c8907ecab82bbaea7a402484755e1e82dd 100644 (file)
@@ -1638,15 +1638,13 @@ If LIMIT, first try to limit the search to the N last articles."
              (setq start-article 1))
            (let* ((unread
                    (gnus-compress-sequence
-                     (seq-difference
-                      (seq-difference
+                    (gnus-set-difference
+                     (gnus-set-difference
                       existing
                       (gnus-sorted-union
                        (cdr (assoc '%Seen flags))
-                        (cdr (assoc '%Deleted flags)))
-                       #'eq)
-                      (cdr (assoc '%Flagged flags))
-                      #'eq)))
+                       (cdr (assoc '%Deleted flags))))
+                     (cdr (assoc '%Flagged flags)))))
                   (read (gnus-range-difference
                          (cons start-article high) unread)))
              (when (> start-article 1)
index 3f978918b9a5dcb6e090524e4b5b5feb65b409e8..d00f0a60b66b5364e8c5eacd2e4fc74b51fca3b5 100644 (file)
@@ -710,8 +710,16 @@ finds ham or spam.")
 (defun spam-set-difference (list1 list2)
   "Return a set difference of LIST1 and LIST2.
 When either list is nil, the other is returned."
-  (declare (obsolete seq-difference "28.1"))
-  (seq-difference list1 list2 #'eq))
+  (if (and list1 list2)
+      ;; we have two non-nil lists
+      (progn
+        (dolist (item (append list1 list2))
+          (when (and (memq item list1) (memq item list2))
+            (setq list1 (delq item list1))
+            (setq list2 (delq item list2))))
+        (append list1 list2))
+    ;; if either of the lists was nil, return the other one
+    (if list1 list1 list2)))
 
 (defun spam-group-ham-mark-p (group mark &optional spam)
   "Checks if MARK is considered a ham mark in GROUP."
@@ -1319,7 +1327,7 @@ In the case of mover backends, checks the setting of
              (new-articles (spam-list-articles
                             gnus-newsgroup-articles
                             classification))
-             (changed-articles (seq-difference new-articles old-articles #'eq)))
+             (changed-articles (spam-set-difference new-articles old-articles)))
         ;; now that we have the changed articles, we go through the processors
         (dolist (backend (spam-backend-list))
           (let (unregister-list)