branch: elpa/elfeed
commit ed427d31ff015d4f60e00c716141b1023aa9fe24
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>
Reapply "elfeed-meta: Cache feeds meta data in elfeed--feeds-meta hash
table"
This reverts commit 8a7b5c8c18aaee1b361d13cc9227acfe9d6b0259.
---
elfeed-db.el | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/elfeed-db.el b/elfeed-db.el
index 0802b79cfd..3ddc064e7a 100644
--- a/elfeed-db.el
+++ b/elfeed-db.el
@@ -458,6 +458,9 @@ Runs `elfeed-db-unload-hook' after unloading the database."
(cl-loop for (k v) on plist by #'cddr
when v collect k and collect v))
+(defvar elfeed--feeds-meta (make-hash-table :test #'eq)
+ "Cache of feed meta data.")
+
(defun elfeed-meta (thing key &optional default)
"Access metadata for THING (entry, feed) under KEY.
Return DEFAULT if unavailable. During `elfeed-db-gc' and
@@ -467,10 +470,16 @@ only list data structures will be scanned (e.g., cons,
list, alist,
plist). The data structures must not be cyclic (e.g., cyclic lists)
since the scanner is not guarded against them."
(or (plist-get (elfeed-meta--plist thing) key)
- (when (and (keywordp key) (elfeed-feed-p thing))
- (let ((url (or (elfeed-feed-url thing)
- (elfeed-feed-id thing))))
- (plist-get (cdr (assoc url elfeed-feeds)) key)))
+ (when (elfeed-feed-p thing)
+ (let ((plist (with-memoization (gethash thing elfeed--feeds-meta)
+ (let ((plist (cdr (assoc (or (elfeed-feed-url thing)
+ (elfeed-feed-id thing))
+ elfeed-feeds))))
+ (or (cl-loop while (keywordp (car plist))
+ collect (pop plist)
+ collect (pop plist))
+ t)))))
+ (and (consp plist) (plist-get plist key))))
default))
(defun elfeed-meta--put (thing key value)