summaryrefslogtreecommitdiff
path: root/lisp/gnus/gnus-dup.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/gnus/gnus-dup.el')
-rw-r--r--lisp/gnus/gnus-dup.el58
1 files changed, 31 insertions, 27 deletions
diff --git a/lisp/gnus/gnus-dup.el b/lisp/gnus/gnus-dup.el
index 8342ca86b67..4981614a17f 100644
--- a/lisp/gnus/gnus-dup.el
+++ b/lisp/gnus/gnus-dup.el
@@ -1,4 +1,4 @@
-;;; gnus-dup.el --- suppression of duplicate articles in Gnus
+;;; gnus-dup.el --- suppression of duplicate articles in Gnus -*- lexical-binding: t -*-
;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
@@ -29,8 +29,6 @@
;;; Code:
-(eval-when-compile (require 'cl))
-
(require 'gnus)
(require 'gnus-art)
@@ -46,7 +44,7 @@ seen in the same session."
:type 'boolean)
(defcustom gnus-duplicate-list-length 10000
- "The number of Message-IDs to keep in the duplicate suppression list."
+ "The maximum number of duplicate Message-IDs to keep track of."
:group 'gnus-duplicate
:type 'integer)
@@ -57,10 +55,14 @@ seen in the same session."
;;; Internal variables
-(defvar gnus-dup-list nil)
-(defvar gnus-dup-hashtb nil)
+(defvar gnus-dup-list nil
+ "List of seen message IDs, as strings.")
+
+(defvar gnus-dup-hashtb nil
+ "Hash table of seen message IDs, for fast lookup.")
-(defvar gnus-dup-list-dirty nil)
+(defvar gnus-dup-list-dirty nil
+ "Non-nil if `gnus-dup-list' needs to be saved.")
;;;
;;; Starting and stopping
@@ -80,10 +82,10 @@ seen in the same session."
(if gnus-save-duplicate-list
(gnus-dup-read)
(setq gnus-dup-list nil))
- (setq gnus-dup-hashtb (gnus-make-hashtable gnus-duplicate-list-length))
+ (setq gnus-dup-hashtb (gnus-make-hashtable))
;; Enter all Message-IDs into the hash table.
- (let ((obarray gnus-dup-hashtb))
- (mapc 'intern gnus-dup-list)))
+ (dolist (g gnus-dup-list)
+ (puthash g t gnus-dup-hashtb)))
(defun gnus-dup-read ()
"Read the duplicate suppression list."
@@ -105,7 +107,7 @@ seen in the same session."
(defun gnus-dup-enter-articles ()
"Enter articles from the current group for future duplicate suppression."
- (unless gnus-dup-list
+ (unless gnus-dup-hashtb
(gnus-dup-open))
(setq gnus-dup-list-dirty t) ; mark list for saving
(let (msgid)
@@ -118,29 +120,30 @@ seen in the same session."
(not (= (gnus-data-mark datum) gnus-canceled-mark))
(setq msgid (mail-header-id (gnus-data-header datum)))
(not (nnheader-fake-message-id-p msgid))
- (not (intern-soft msgid gnus-dup-hashtb)))
+ (not (gethash msgid gnus-dup-hashtb)))
(push msgid gnus-dup-list)
- (intern msgid gnus-dup-hashtb))))
- ;; Chop off excess Message-IDs from the list.
- (let ((end (nthcdr gnus-duplicate-list-length gnus-dup-list)))
+ (puthash msgid t gnus-dup-hashtb))))
+ ;; Remove excess Message-IDs from the list and hash table.
+ (let* ((dups (cons nil gnus-dup-list))
+ (end (nthcdr gnus-duplicate-list-length dups)))
(when end
- (mapc (lambda (id) (unintern id gnus-dup-hashtb)) (cdr end))
- (setcdr end nil))))
+ (mapc (lambda (id) (remhash id gnus-dup-hashtb)) (cdr end))
+ (setcdr end nil))
+ (setq gnus-dup-list (cdr dups))))
(defun gnus-dup-suppress-articles ()
"Mark duplicate articles as read."
- (unless gnus-dup-list
+ (unless gnus-dup-hashtb
(gnus-dup-open))
(gnus-message 8 "Suppressing duplicates...")
(let ((auto (and gnus-newsgroup-auto-expire
(memq gnus-duplicate-mark gnus-auto-expirable-marks)))
number)
(dolist (header gnus-newsgroup-headers)
- (when (and (intern-soft (mail-header-id header) gnus-dup-hashtb)
- (gnus-summary-article-unread-p (mail-header-number header)))
- (setq gnus-newsgroup-unreads
- (delq (setq number (mail-header-number header))
- gnus-newsgroup-unreads))
+ (when (and (gethash (mail-header-id header) gnus-dup-hashtb)
+ (setq number (mail-header-number header))
+ (gnus-summary-article-unread-p number))
+ (setq gnus-newsgroup-unreads (delq number gnus-newsgroup-unreads))
(if (not auto)
(push (cons number gnus-duplicate-mark) gnus-newsgroup-reads)
(push number gnus-newsgroup-expirable)
@@ -149,12 +152,13 @@ seen in the same session."
(defun gnus-dup-unsuppress-article (article)
"Stop suppression of ARTICLE."
- (let* ((header (gnus-data-header (gnus-data-find article)))
- (id (when header (mail-header-id header))))
- (when id
+ (let (header id)
+ (when (and gnus-dup-hashtb
+ (setq header (gnus-data-header (gnus-data-find article)))
+ (setq id (mail-header-id header)))
(setq gnus-dup-list-dirty t)
(setq gnus-dup-list (delete id gnus-dup-list))
- (unintern id gnus-dup-hashtb))))
+ (remhash id gnus-dup-hashtb))))
(provide 'gnus-dup)