[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 2a4e5a8e58 02/31: org-persist--normalize-associated
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 2a4e5a8e58 02/31: org-persist--normalize-associated: Use cache to calculate buffer hash |
Date: |
Sat, 29 Jan 2022 04:57:57 -0500 (EST) |
branch: externals/org
commit 2a4e5a8e58f381497b5b53e96691ac2eaf98bdcd
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
org-persist--normalize-associated: Use cache to calculate buffer hash
---
lisp/org-persist.el | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 9fee5f7936..413c7790d8 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -355,6 +355,9 @@ or file-path, (:inode inode), (:hash hash), or or (:key
key)."
container)
(_ (error "org-persist: Unknown container type: %S" container)))))
+(defvar org-persist--associated-buffer-cache (make-hash-table :weakness 'key)
+ "Buffer hash cache.")
+
(defun org-persist--normalize-associated (associated)
"Normalize ASSOCIATED representation into (:type value)."
(pcase associated
@@ -368,14 +371,26 @@ or file-path, (:inode inode), (:hash hash), or or (:key
key)."
rtn))
((or (pred bufferp) `(:buffer ,associated2))
(when associated2 (setq associated associated2))
- (let* ((file (buffer-file-name
- (or (buffer-base-buffer associated)
- associated)))
- (inode (when (and file
- (fboundp 'file-attribute-inode-number))
- (file-attribute-inode-number
- (file-attributes file))))
- (hash (secure-hash 'md5 associated)))
+ (let ((cached (gethash associated org-persist--associated-buffer-cache))
+ file inode hash)
+ (if (and cached (eq (buffer-modified-tick associated)
+ (car cached)))
+ (progn
+ (setq file (nth 1 cached)
+ inode (nth 2 cached)
+ hash (nth 3 cached)))
+ (setq file (buffer-file-name
+ (or (buffer-base-buffer associated)
+ associated)))
+ (setq inode (when (and file
+ (fboundp 'file-attribute-inode-number))
+ (file-attribute-inode-number
+ (file-attributes file))))
+ (setq hash (secure-hash 'md5 associated))
+ (puthash associated
+ (list (buffer-modified-tick associated)
+ file inode hash)
+ org-persist--associated-buffer-cache))
(let ((rtn `(:hash ,hash)))
(when file (setq rtn (plist-put rtn :file file)))
(when inode (setq rtn (plist-put rtn :inode inode)))
- [elpa] externals/org updated (22e6ed6b89 -> ac5742f296), ELPA Syncer, 2022/01/29
- [elpa] externals/org 2a4e5a8e58 02/31: org-persist--normalize-associated: Use cache to calculate buffer hash,
ELPA Syncer <=
- [elpa] externals/org 703df9310a 07/31: org-persist: Cleanup on removal and version mismatch, ELPA Syncer, 2022/01/29
- [elpa] externals/org dafa32da49 06/31: org-persist: Update index version, ELPA Syncer, 2022/01/29
- [elpa] externals/org f963d617a4 14/31: Fix checkdoc warnings, ELPA Syncer, 2022/01/29
- [elpa] externals/org 9b650938e7 13/31: org-persist: Provide human readable access time and make sure it exist, ELPA Syncer, 2022/01/29
- [elpa] externals/org 1869a37a2c 10/31: Fix org-persist--remove-from-index, ELPA Syncer, 2022/01/29
- [elpa] externals/org aca62116da 12/31: org-persist-write: Update buffer hash on save, ELPA Syncer, 2022/01/29
- [elpa] externals/org edd7f2962f 01/31: org-persist: Reimplement using more generic approach, ELPA Syncer, 2022/01/29
- [elpa] externals/org 7c2d93560c 03/31: org-persist-default-expiry: Introduce and change default, ELPA Syncer, 2022/01/29
- [elpa] externals/org 1084566322 08/31: Fix org-persist-unregister, ELPA Syncer, 2022/01/29
- [elpa] externals/org d5fc159bf7 15/31: Fix compiler warnings, ELPA Syncer, 2022/01/29