aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Abrahamsen2019-02-04 12:55:29 -0800
committerEric Abrahamsen2019-02-04 13:37:50 -0800
commita1b83539024e2ce778597ba6862df760cf7e0fcd (patch)
treeee20915ac952f869a17c842a152a61f55431e1e3
parent80ae16ffa7af5b191d311c40c0ff5405a8e101ef (diff)
downloademacs-scratch/gnus-hashtables.tar.gz
emacs-scratch/gnus-hashtables.zip
Don't use a hashtable in gnus-backlogscratch/gnus-hashtables
* 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.
-rw-r--r--lisp/gnus/gnus-bcklg.el46
1 files changed, 20 insertions, 26 deletions
diff --git a/lisp/gnus/gnus-bcklg.el b/lisp/gnus/gnus-bcklg.el
index 77f1f2a1220..17513c5a8af 100644
--- a/lisp/gnus/gnus-bcklg.el
+++ b/lisp/gnus/gnus-bcklg.el
@@ -22,16 +22,16 @@
22 22
23;;; Commentary: 23;;; Commentary:
24 24
25;; The backlog caches the text of a certain number of read articles in
26;; a separate buffer, so they can be retrieved quickly if the user
27;; opens them again. Also see `gnus-keep-backlog'.
28
25;;; Code: 29;;; Code:
26 30
27(require 'gnus) 31(require 'gnus)
28 32
29;;;
30;;; Buffering of read articles.
31;;;
32
33(defvar gnus-backlog-buffer " *Gnus Backlog*") 33(defvar gnus-backlog-buffer " *Gnus Backlog*")
34(defvar gnus-backlog-hashtb nil) 34(defvar gnus-backlog-articles '())
35 35
36(defun gnus-backlog-buffer () 36(defun gnus-backlog-buffer ()
37 "Return the backlog buffer." 37 "Return the backlog buffer."
@@ -41,11 +41,6 @@
41 (setq buffer-read-only t) 41 (setq buffer-read-only t)
42 (get-buffer gnus-backlog-buffer)))) 42 (get-buffer gnus-backlog-buffer))))
43 43
44(defun gnus-backlog-setup ()
45 "Initialize backlog variables."
46 (unless gnus-backlog-hashtb
47 (setq gnus-backlog-hashtb (gnus-make-hashtable 1000))))
48
49(gnus-add-shutdown 'gnus-backlog-shutdown 'gnus) 44(gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
50 45
51(defun gnus-backlog-shutdown () 46(defun gnus-backlog-shutdown ()
@@ -53,20 +48,19 @@
53 (interactive) 48 (interactive)
54 (when (get-buffer gnus-backlog-buffer) 49 (when (get-buffer gnus-backlog-buffer)
55 (gnus-kill-buffer gnus-backlog-buffer)) 50 (gnus-kill-buffer gnus-backlog-buffer))
56 (setq gnus-backlog-hashtb nil)) 51 (setq gnus-backlog-articles nil))
57 52
58(defun gnus-backlog-enter-article (group number buffer) 53(defun gnus-backlog-enter-article (group number buffer)
59 (when (and (numberp number) 54 (when (and (numberp number)
60 (not (gnus-virtual-group-p group))) 55 (not (gnus-virtual-group-p group)))
61 (gnus-backlog-setup) 56 (let ((ident (format "%s:%d" group number))
62 (let ((ident (concat group ":" (int-to-string number)))
63 b) 57 b)
64 (unless (gethash ident gnus-backlog-hashtb) ; It's already kept. 58 (unless (member ident gnus-backlog-articles) ; It's already kept.
65 ;; Remove the oldest article, if necessary. 59 ;; Remove the oldest article, if necessary.
66 (and (numberp gnus-keep-backlog) 60 (and (numberp gnus-keep-backlog)
67 (>= (hash-table-count gnus-backlog-hashtb) gnus-keep-backlog) 61 (>= (length gnus-backlog-articles) gnus-keep-backlog)
68 (gnus-backlog-remove-oldest-article)) 62 (gnus-backlog-remove-oldest-article))
69 (puthash ident t gnus-backlog-hashtb) 63 (push ident gnus-backlog-articles)
70 ;; Insert the new article. 64 ;; Insert the new article.
71 (with-current-buffer (gnus-backlog-buffer) 65 (with-current-buffer (gnus-backlog-buffer)
72 (let (buffer-read-only) 66 (let (buffer-read-only)
@@ -88,7 +82,8 @@
88 buffer-read-only) 82 buffer-read-only)
89 ;; Remove the ident from the list of articles. 83 ;; Remove the ident from the list of articles.
90 (when ident 84 (when ident
91 (remhash ident gnus-backlog-hashtb)) 85 (setq gnus-backlog-articles
86 (delete ident gnus-backlog-articles)))
92 ;; Delete the article itself. 87 ;; Delete the article itself.
93 (delete-region 88 (delete-region
94 (point) (next-single-property-change 89 (point) (next-single-property-change
@@ -97,10 +92,9 @@
97(defun gnus-backlog-remove-article (group number) 92(defun gnus-backlog-remove-article (group number)
98 "Remove article NUMBER in GROUP from the backlog." 93 "Remove article NUMBER in GROUP from the backlog."
99 (when (numberp number) 94 (when (numberp number)
100 (gnus-backlog-setup) 95 (let ((ident (format "%s:%d" group number))
101 (let ((ident (concat group ":" (int-to-string number)))
102 beg) 96 beg)
103 (when (gethash ident gnus-backlog-hashtb) 97 (when (member ident gnus-backlog-articles)
104 ;; It was in the backlog. 98 ;; It was in the backlog.
105 (with-current-buffer (gnus-backlog-buffer) 99 (with-current-buffer (gnus-backlog-buffer)
106 (save-excursion 100 (save-excursion
@@ -108,7 +102,6 @@
108 (goto-char (point-min)) 102 (goto-char (point-min))
109 (when (setq beg (gnus-text-property-search 103 (when (setq beg (gnus-text-property-search
110 'gnus-backlog ident)) 104 'gnus-backlog ident))
111 (setq beg (prop-match-beginning beg))
112 ;; Find the end (i. e., the beginning of the next article). 105 ;; Find the end (i. e., the beginning of the next article).
113 (goto-char 106 (goto-char
114 (next-single-property-change 107 (next-single-property-change
@@ -116,22 +109,23 @@
116 (delete-region beg (point)) 109 (delete-region beg (point))
117 ;; Return success. 110 ;; Return success.
118 t))) 111 t)))
119 (remhash ident gnus-backlog-hashtb)))))) 112 (setq gnus-backlog-articles
113 (delete ident gnus-backlog-articles)))))))
120 114
121(defun gnus-backlog-request-article (group number &optional buffer) 115(defun gnus-backlog-request-article (group number &optional buffer)
122 (when (and (numberp number) 116 (when (and (numberp number)
123 (not (gnus-virtual-group-p group))) 117 (not (gnus-virtual-group-p group)))
124 (gnus-backlog-setup) 118 (let ((ident (format "%s:%d" group number))
125 (let ((ident (concat group ":" (int-to-string number)))
126 beg end) 119 beg end)
127 (when (gethash ident gnus-backlog-hashtb) 120 (when (member ident gnus-backlog-articles)
128 ;; It was in the backlog. 121 ;; It was in the backlog.
129 (with-current-buffer (gnus-backlog-buffer) 122 (with-current-buffer (gnus-backlog-buffer)
130 (if (not (setq beg (gnus-text-property-search 123 (if (not (setq beg (gnus-text-property-search
131 'gnus-backlog ident))) 124 'gnus-backlog ident)))
132 ;; It wasn't in the backlog after all. 125 ;; It wasn't in the backlog after all.
133 (ignore 126 (ignore
134 (remhash ident gnus-backlog-hashtb)) 127 (setq gnus-backlog-articles
128 (delete ident gnus-backlog-articles)))
135 ;; Find the end (i. e., the beginning of the next article). 129 ;; Find the end (i. e., the beginning of the next article).
136 (setq end 130 (setq end
137 (next-single-property-change 131 (next-single-property-change