summaryrefslogtreecommitdiff
path: root/lisp/gnus/gnus-dup.el
diff options
context:
space:
mode:
authorEric Abrahamsen <eric@ericabrahamsen.net>2018-04-26 16:26:27 -0700
committerEric Abrahamsen <eric@ericabrahamsen.net>2019-03-22 10:23:30 -0700
commitc1b63af4458e92bad33da0def2b15c206656e2fa (patch)
tree267503989ec0475b76800bb309f6cdc1da53e74e /lisp/gnus/gnus-dup.el
parent3375d08299bbc1e224d19a871012cdbbf5d787ee (diff)
downloademacs-c1b63af4458e92bad33da0def2b15c206656e2fa.tar.gz
Change Gnus hash tables into real hash tables
Gnus has used obarrays as makeshift hash tables for groups: group names are coerced to unibyte and interned in custom obarrays, and their symbol-value set to whatever value needs to be stored. This patch replaces those obarrays with actual hash tables. * lisp/gnus/gnus-util.el (gnus-intern-safe, gnus-create-hash-size): Remove functions. (gnus-make-hashtable): Change to return a real hash table. (gnus-text-property-search): Utility similar to `text-property-any', but compares on `equal'. Needed because the 'gnus-group text property is now a string. * lisp/gnus/gnus.el (gnus-gethash, gnus-gethash-safe, gnus-sethash): Remove macros. (gnus-group-list): New variable holding all group names as an ordered list. Used because `gnus-newsrc-hashtb' used to preserve `gnus-newsrc-alist' ordering, but now doesn't. * lisp/gnus/nnmaildir.el (nnmaildir--servers): Change from obarray to alist. (nnmaildir--up2-1): Remove function. * lisp/thingatpt.el (thing-at-point-newsgroup-p): This was making use of Gnus obarrays, replace with a cond that can handle many different possibilities. * lisp/gnus/gnus-bcklg.el (gnus-backlog-articles): Remove gnus-backlog-hashtb, which wasn't doing anything. Just keep a list of ident strings in gnus-backlog-articles. (gnus-backlog-setup): Delete unnecessary function. (gnus-backlog-enter-article, gnus-backlog-remove-oldest-article, gnus-backlog-remove-article, gnus-backlog-request-article): Alter calls accordingly. * lisp/gnus/gnus-dup.el (gnus-duplicate-list-max-length): Rename from `gnus-duplicate-list-length', for accuracy. * lisp/gnus/gnus-start.el (gnus-active-to-gnus-format, gnus-groups-to-gnus-format, gnus-newsrc-to-gnus-format): Read group names as strings. (gnus-gnus-to-quick-newsrc-format): Write `gnus-newsrc-alist' using the ordering in `gnus-group-list'. * lisp/gnus/gnus-agent.el: * lisp/gnus/gnus-async.el: * lisp/gnus/gnus-cache.el: * lisp/gnus/gnus-group.el: * lisp/gnus/gnus-score.el: * lisp/gnus/gnus-sum.el: * lisp/gnus/gnus-topic.el: * lisp/gnus/message.el: * lisp/gnus/mml.el: * lisp/gnus/nnagent.el: * lisp/gnus/nnbabyl.el: * lisp/gnus/nnvirtual.el: * lisp/gnus/nnweb.el: In all files, change obarrays to hash-tables, and swap `gnus-sethash' for `puthash', `gnus-gethash' for `gethash', `mapatoms' for `maphash', etc. * test/lisp/gnus/gnus-test-headers.el (gnus-headers-make-dependency-table, gnus-headers-loop-dependencies): New tests to make sure we're building `gnus-newsgroup-dependencies' correctly.
Diffstat (limited to 'lisp/gnus/gnus-dup.el')
-rw-r--r--lisp/gnus/gnus-dup.el22
1 files changed, 12 insertions, 10 deletions
diff --git a/lisp/gnus/gnus-dup.el b/lisp/gnus/gnus-dup.el
index 5c085f95aa7..8b876489e1c 100644
--- a/lisp/gnus/gnus-dup.el
+++ b/lisp/gnus/gnus-dup.el
@@ -44,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)
@@ -55,8 +55,10 @@ 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)
@@ -80,8 +82,8 @@ seen in the same session."
(setq gnus-dup-list nil))
(setq gnus-dup-hashtb (gnus-make-hashtable gnus-duplicate-list-length))
;; 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."
@@ -116,13 +118,13 @@ 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))))
+ (puthash msgid t gnus-dup-hashtb))))
;; Chop off excess Message-IDs from the list.
(let ((end (nthcdr gnus-duplicate-list-length gnus-dup-list)))
(when end
- (mapc (lambda (id) (unintern id gnus-dup-hashtb)) (cdr end))
+ (mapc (lambda (id) (remhash id gnus-dup-hashtb)) (cdr end))
(setcdr end nil))))
(defun gnus-dup-suppress-articles ()
@@ -134,7 +136,7 @@ seen in the same session."
(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)
+ (when (and (gethash (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))
@@ -152,7 +154,7 @@ seen in the same session."
(when id
(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)