emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals-release/org fa5c832e9b 2/2: org-cite-basic--key-complet


From: ELPA Syncer
Subject: [elpa] externals-release/org fa5c832e9b 2/2: org-cite-basic--key-completion-table: Reuse bibliography for speed
Date: Sat, 16 Apr 2022 06:57:46 -0400 (EDT)

branch: externals-release/org
commit fa5c832e9b8c3f07197df112d2068c8361354736
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>

    org-cite-basic--key-completion-table: Reuse bibliography for speed
    
    * lisp/oc-basic.el (org-cite-basic--key-completion-table): Supply the
    pre-calculated bibliography entries when getting entry fields.  This
    avoids excessive file change checks inside
    `org-cite-basic--parse-bibliography'.
---
 lisp/oc-basic.el | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/lisp/oc-basic.el b/lisp/oc-basic.el
index 8af150b73a..775690f176 100644
--- a/lisp/oc-basic.el
+++ b/lisp/oc-basic.el
@@ -734,19 +734,24 @@ Return nil if there are no bibliography files or no 
entries."
      (t
       (clrhash org-cite-basic--completion-cache)
       (dolist (key (org-cite-basic--all-keys))
-        (let ((completion
-               (concat
-                (let ((author (org-cite-basic--get-field 'author key nil t)))
-                  (if author
-                      (truncate-string-to-width
-                       (replace-regexp-in-string " and " "; " author)
-                       org-cite-basic-author-column-end nil ?\s)
-                    (make-string org-cite-basic-author-column-end ?\s)))
-                org-cite-basic-column-separator
-                (let ((date (org-cite-basic--get-year key nil 'no-suffix)))
-                  (format "%4s" (or date "")))
-                org-cite-basic-column-separator
-                (org-cite-basic--get-field 'title key nil t))))
+        (let* ((entry (org-cite-basic--get-entry
+                       key
+                       ;; Supply pre-calculated bibliography to avoid
+                       ;; performance degradation.
+                       (list :cite-basic/bibliography entries)))
+               (completion
+                (concat
+                 (let ((author (org-cite-basic--get-field 'author entry nil 
'raw)))
+                   (if author
+                       (truncate-string-to-width
+                        (replace-regexp-in-string " and " "; " author)
+                        org-cite-basic-author-column-end nil ?\s)
+                     (make-string org-cite-basic-author-column-end ?\s)))
+                 org-cite-basic-column-separator
+                 (let ((date (org-cite-basic--get-year entry nil 'no-suffix)))
+                   (format "%4s" (or date "")))
+                 org-cite-basic-column-separator
+                 (org-cite-basic--get-field 'title entry nil t))))
           (puthash completion key org-cite-basic--completion-cache)))
       (unless (map-empty-p org-cite-basic--completion-cache) ;no key
         (puthash entries t org-cite-basic--completion-cache)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]