[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master f94e93a6ee 7/9: org-cite-list-citations: Cache footnote-definitio
From: |
Eli Zaretskii |
Subject: |
master f94e93a6ee 7/9: org-cite-list-citations: Cache footnote-definition searches |
Date: |
Thu, 16 Jun 2022 04:09:45 -0400 (EDT) |
branch: master
commit f94e93a6eec92d834a6b545d8d4b68280b0993b0
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Eli Zaretskii <eliz@gnu.org>
org-cite-list-citations: Cache footnote-definition searches
* lisp/org/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/org/oc.el | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/lisp/org/oc.el b/lisp/org/oc.el
index eb5f519cb6..c4cd0268c7 100644
--- a/lisp/org/oc.el
+++ b/lisp/org/oc.el
@@ -808,6 +808,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
@@ -816,11 +818,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)
@@ -834,7 +846,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)))
- master updated (fdd4dc6bdf -> 217c41c7b0), Eli Zaretskii, 2022/06/16
- master d21412df06 3/9: org-export-resolve-id-link: Pre-cache all the ids in the parse tree, Eli Zaretskii, 2022/06/16
- master 5b3d4e7bf0 1/9: org-export-get-footnote-definition: Pre-cache references in parse tree, Eli Zaretskii, 2022/06/16
- master 3236dedc2d 2/9: org-export-resolve-fuzyy-link: Pre-cache all possible search cells, Eli Zaretskii, 2022/06/16
- master 217c41c7b0 9/9: Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs, Eli Zaretskii, 2022/06/16
- master f94e93a6ee 7/9: org-cite-list-citations: Cache footnote-definition searches,
Eli Zaretskii <=
- master 0f7ceb4803 4/9: org-export-as: Do not update buffer settings when not modified, Eli Zaretskii, 2022/06/16
- master 979308b4ca 5/9: org-export-data: Concatenate strings in temporary buffer for performance, Eli Zaretskii, 2022/06/16
- master 4f37a3b299 6/9: org-element-map: Avoid repetitive `plist-get' call, Eli Zaretskii, 2022/06/16
- master b3cbcebd9a 8/9: Speed up Org to Texinfo generation, Eli Zaretskii, 2022/06/16