diff options
author | Eric Abrahamsen <eric@ericabrahamsen.net> | 2018-04-26 16:26:27 -0700 |
---|---|---|
committer | Eric Abrahamsen <eric@ericabrahamsen.net> | 2019-03-22 10:23:30 -0700 |
commit | c1b63af4458e92bad33da0def2b15c206656e2fa (patch) | |
tree | 267503989ec0475b76800bb309f6cdc1da53e74e /lisp/gnus/gnus.el | |
parent | 3375d08299bbc1e224d19a871012cdbbf5d787ee (diff) | |
download | emacs-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.el')
-rw-r--r-- | lisp/gnus/gnus.el | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el index 0bd15f3e392..989347c9fd1 100644 --- a/lisp/gnus/gnus.el +++ b/lisp/gnus/gnus.el @@ -29,7 +29,8 @@ (run-hooks 'gnus-load-hook) -(eval-when-compile (require 'cl-lib)) +(eval-when-compile (require 'cl-lib) + (require 'subr-x)) (require 'wid-edit) (require 'mm-util) (require 'nnheader) @@ -2453,28 +2454,37 @@ such as a mark that says whether an article is stored in the cache gnus-registry.el will populate this if it's loaded.") (defvar gnus-newsrc-hashtb nil - "Hashtable of `gnus-newsrc-alist'.") + "Hash table of `gnus-newsrc-alist'.") + +(defvar gnus-group-list nil + "Ordered list of group names as strings. +This variable only exists to provide easy access to the ordering +of `gnus-newsrc-alist'.") (defvar gnus-killed-list nil "List of killed newsgroups.") (defvar gnus-killed-hashtb nil - "Hash table equivalent of `gnus-killed-list'.") + "Hash table equivalent of `gnus-killed-list'. +This is a hash table purely for the fast membership test: values +are always t.") (defvar gnus-zombie-list nil "List of almost dead newsgroups.") (defvar gnus-description-hashtb nil - "Descriptions of newsgroups.") + "Hash table mapping group names to their descriptions.") (defvar gnus-list-of-killed-groups nil "List of newsgroups that have recently been killed by the user.") (defvar gnus-active-hashtb nil - "Hashtable of active articles.") + "Hash table mapping group names to their active entry.") (defvar gnus-moderated-hashtb nil - "Hashtable of moderated newsgroups.") + "Hash table of moderated groups. +This is a hash table purely for the fast membership test: values +are always t.") ;; Save window configuration. (defvar gnus-prev-winconf nil) @@ -2800,36 +2810,21 @@ See Info node `(gnus)Formatting Variables'." (defun gnus-header-from (header) (mail-header-from header)) -(defmacro gnus-gethash (string hashtable) - "Get hash value of STRING in HASHTABLE." - `(symbol-value (intern-soft ,string ,hashtable))) - -(defmacro gnus-gethash-safe (string hashtable) - "Get hash value of STRING in HASHTABLE. -Return nil if not defined." - `(let ((sym (intern-soft ,string ,hashtable))) - (and (boundp sym) (symbol-value sym)))) - -(defmacro gnus-sethash (string value hashtable) - "Set hash value. Arguments are STRING, VALUE, and HASHTABLE." - `(set (intern ,string ,hashtable) ,value)) -(put 'gnus-sethash 'edebug-form-spec '(form form form)) - (defmacro gnus-group-unread (group) "Get the currently computed number of unread articles in GROUP." - `(car (gnus-gethash ,group gnus-newsrc-hashtb))) + `(car (gethash ,group gnus-newsrc-hashtb))) (defmacro gnus-group-entry (group) "Get the newsrc entry for GROUP." - `(gnus-gethash ,group gnus-newsrc-hashtb)) + `(gethash ,group gnus-newsrc-hashtb)) (defmacro gnus-active (group) "Get active info on GROUP." - `(gnus-gethash ,group gnus-active-hashtb)) + `(gethash ,group gnus-active-hashtb)) (defmacro gnus-set-active (group active) "Set GROUP's active info." - `(gnus-sethash ,group ,active gnus-active-hashtb)) + `(puthash ,group ,active gnus-active-hashtb)) ;; Info access macros. @@ -2893,10 +2888,10 @@ Return nil if not defined." (setcar rank (cons (car rank) ,score))))) (defmacro gnus-get-info (group) - `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb))) + `(nth 1 (gethash ,group gnus-newsrc-hashtb))) (defun gnus-set-info (group info) - (setcar (nthcdr 2 (gnus-gethash group gnus-newsrc-hashtb)) + (setcdr (gethash group gnus-newsrc-hashtb) info)) @@ -3185,7 +3180,7 @@ that that variable is buffer-local to the summary buffers." (defun gnus-kill-ephemeral-group (group) "Remove ephemeral GROUP from relevant structures." - (gnus-sethash group nil gnus-newsrc-hashtb)) + (remhash group gnus-newsrc-hashtb)) (defun gnus-simplify-mode-line () "Make mode lines a bit simpler." |