[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 4487acc630 5/7: org-element-cache: Do not compare b
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 4487acc630 5/7: org-element-cache: Do not compare buffer positions with cache keys |
Date: |
Thu, 9 Jun 2022 04:58:10 -0400 (EDT) |
branch: externals/org
commit 4487acc63048ae22d825bb5edc05ccdc2880bf71
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
org-element-cache: Do not compare buffer positions with cache keys
* lisp/org-element.el (org-element--cache-key-less-p): Clarify that
comparison between buffer points and cache keys is not reliable.
(org-element--cache-find): Do not compare POS with cache keys.
(org-element-at-point): Use cache BEG field to determine the cached
buffer portion.
---
lisp/org-element.el | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/lisp/org-element.el b/lisp/org-element.el
index cbd0dd3d57..f1a45a1af8 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -5656,7 +5656,11 @@ lesser than UPPER, per `org-element--cache-key-less-p'."
(defsubst org-element--cache-key-less-p (a b)
"Non-nil if key A is less than key B.
A and B are either integers or lists of integers, as returned by
-`org-element--cache-key'."
+`org-element--cache-key'.
+
+Note that it is not reliable to compare buffer position with the cache
+keys. They keys may be larger compared to actual element :begin
+position."
(if (integerp a) (if (integerp b) (< a b) (<= a (car b)))
(if (integerp b) (< (car a) b)
(catch 'exit
@@ -5762,7 +5766,9 @@ the cache."
(if (and hashed (not (eq side 'both))
(or (not limit)
;; Limit can be a list key.
- (org-element--cache-key-less-p pos limit))
+ (org-element--cache-key-less-p
+ (org-element--cache-key hashed)
+ limit))
(= pos (org-element-property :begin hashed))
;; We cannot rely on element :begin for elements with
;; children starting at the same pos.
@@ -7829,10 +7835,12 @@ element ending there."
(if (not org-element--cache) (org-element-cache-reset)
(unless cached-only (org-element--cache-sync (current-buffer) pom))))
(setq element (if cached-only
- (and (org-element--cache-active-p)
- (or (not org-element--cache-sync-requests)
- (org-element--cache-key-less-p pom
(org-element--request-key (car org-element--cache-sync-requests))))
- (org-element--cache-find pom))
+ (when (and (org-element--cache-active-p)
+ (or (not org-element--cache-sync-requests)
+ (< pom
+ (org-element--request-beg
+ (car
org-element--cache-sync-requests)))))
+ (org-element--cache-find pom))
(condition-case err
(org-element--parse-to pom)
(error
- [elpa] externals/org updated (c02c0d660d -> d9963c58dc), ELPA Syncer, 2022/06/09
- [elpa] externals/org 819409baab 4/7: org-get-buffer-tags: Improve performance, ELPA Syncer, 2022/06/09
- [elpa] externals/org 0e7033e0ca 6/7: org-capture: Expand sexps in template with Org mode being active, ELPA Syncer, 2022/06/09
- [elpa] externals/org d9963c58dc 7/7: lisp/ol.el: Fix shadowed radio targets, ELPA Syncer, 2022/06/09
- [elpa] externals/org 96746438c0 1/7: org-element--cache-find: Do not hash section/org-data/table elements, ELPA Syncer, 2022/06/09
- [elpa] externals/org 46df681336 2/7: org.el: Improve performance of deletion commands, ELPA Syncer, 2022/06/09
- [elpa] externals/org 4487acc630 5/7: org-element-cache: Do not compare buffer positions with cache keys,
ELPA Syncer <=
- [elpa] externals/org 93821b431c 3/7: org-element--cache-for-removal: Improve performance, ELPA Syncer, 2022/06/09