org-element: Implement caching for dynamic parser
authorNicolas Goaziou <n.goaziou@gmail.com>
Sun, 27 Oct 2013 10:09:17 +0000 (11:09 +0100)
committerNicolas Goaziou <n.goaziou@gmail.com>
Sun, 3 Nov 2013 12:09:54 +0000 (13:09 +0100)
commit0cecf32a0ae559266555b96668dc305710366c96
tree747812692b31525be479384854aea76a3fa22df7
parent1bf67e2903a62df05ad23d95d02f8d83517eb427
org-element: Implement caching for dynamic parser

* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.

This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
lisp/org-element.el
lisp/org-footnote.el
lisp/org.el
testing/lisp/test-org-element.el