[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org b061e7b61c 5/8: org-cite-list-citations: Cache foot
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org b061e7b61c 5/8: org-cite-list-citations: Cache footnote-definition searches |
Date: |
Thu, 16 Jun 2022 02:02:36 -0400 (EDT) |
branch: externals/org
commit b061e7b61c65bd676bd146bdf91d4b13b0927ebb
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
org-cite-list-citations: Cache footnote-definition searches
* lisp/oc.el (org-cite-list-citations): Avoid quadratic complexity.
Pre-calculate list of all footnote definitions and cache the footnote
label search hits. Do not make `org-element-map' accumulate unused
result.
---
lisp/oc.el | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/lisp/oc.el b/lisp/oc.el
index 360f1fadcf..4dcb3f57c2 100644
--- a/lisp/oc.el
+++ b/lisp/oc.el
@@ -854,6 +854,8 @@ INFO is the export communication channel, as a property
list."
(or (plist-get info :citations)
(letrec ((cites nil)
(tree (plist-get info :parse-tree))
+ (definition-cache (make-hash-table :test #'equal))
+ (definition-list nil)
(find-definition
;; Find definition for standard reference LABEL. At
;; this point, it is impossible to rely on
@@ -862,11 +864,21 @@ INFO is the export communication channel, as a property
list."
;; un-processed citation objects. So we use
;; a simplified version of the function above.
(lambda (label)
- (org-element-map tree 'footnote-definition
- (lambda (d)
- (and (equal label (org-element-property :label d))
- (or (org-element-contents d) "")))
- info t)))
+ (or (gethash label definition-cache)
+ (org-element-map
+ (or definition-list
+ (setq definition-list
+ (org-element-map
+ tree
+ 'footnote-definition
+ #'identity info)))
+ 'footnote-definition
+ (lambda (d)
+ (and (equal label (org-element-property :label d))
+ (puthash label
+ (or (org-element-contents d) "")
+ definition-cache)))
+ info t))))
(search-cites
(lambda (data)
(org-element-map data '(citation footnote-reference)
@@ -880,7 +892,8 @@ INFO is the export communication channel, as a property
list."
(_
(let ((label (org-element-property :label datum)))
(funcall search-cites
- (funcall find-definition label))))))
+ (funcall find-definition label)))))
+ nil)
info nil 'footnote-definition t))))
(funcall search-cites tree)
(let ((result (nreverse cites)))
- [elpa] externals/org updated (aa789b89d7 -> 3bbbf77f36), ELPA Syncer, 2022/06/16
- [elpa] externals/org 8f59e8d93f 7/8: Fix native-comp warnings, ELPA Syncer, 2022/06/16
- [elpa] externals/org e273fa96e5 6/8: Fix function declarations, ELPA Syncer, 2022/06/16
- [elpa] externals/org b061e7b61c 5/8: org-cite-list-citations: Cache footnote-definition searches,
ELPA Syncer <=
- [elpa] externals/org 3bbbf77f36 8/8: org-babel-exp-process-buffer: Improve performance, ELPA Syncer, 2022/06/16
- [elpa] externals/org a158b263a6 3/8: org-export-data: Concatenate strings in temporary buffer for performance, ELPA Syncer, 2022/06/16
- [elpa] externals/org 37a447ae08 4/8: org-element-map: Avoid repetitive `plist-get' call, ELPA Syncer, 2022/06/16
- [elpa] externals/org 3684c79672 2/8: doc/Makefile: Disable GC during export, ELPA Syncer, 2022/06/16
- [elpa] externals/org 076dd92acc 1/8: org-export-as: Do not update buffer settings when not modified, ELPA Syncer, 2022/06/16