mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-25 07:32:52 +00:00
org-fold-core-next-folding-state-change: Optimize performance
* lisp/org-fold-core.el (org-fold-core-next-folding-state-change): Avoid repetitive searches all to way to LIMIT. Instead, limit the next searches by the limit computer by previous.
This commit is contained in:
parent
17096b3f4c
commit
c9b80f06d4
|
@ -910,14 +910,19 @@ Search backwards when PREVIOUS-P is non-nil."
|
||||||
(unless spec-or-alias
|
(unless spec-or-alias
|
||||||
(setq spec-or-alias (org-fold-core-folding-spec-list)))
|
(setq spec-or-alias (org-fold-core-folding-spec-list)))
|
||||||
(setq pos (or pos (point)))
|
(setq pos (or pos (point)))
|
||||||
(apply (if previous-p
|
(let ((limit (or limit (if previous-p (point-min) (point-max)))))
|
||||||
#'max
|
(catch :limit
|
||||||
#'min)
|
(dolist (prop (mapcar
|
||||||
(mapcar (if previous-p
|
(lambda (el)
|
||||||
(lambda (prop) (max (or limit (point-min)) (previous-single-char-property-change pos prop nil (or limit (point-min)))))
|
(org-fold-core--property-symbol-get-create el nil t))
|
||||||
(lambda (prop) (next-single-char-property-change pos prop nil (or limit (point-max)))))
|
spec-or-alias))
|
||||||
(mapcar (lambda (el) (org-fold-core--property-symbol-get-create el nil t))
|
(when (= limit pos) (throw :limit limit))
|
||||||
spec-or-alias))))
|
(setq
|
||||||
|
limit
|
||||||
|
(if previous-p
|
||||||
|
(previous-single-char-property-change pos prop nil limit)
|
||||||
|
(next-single-char-property-change pos prop nil limit))))
|
||||||
|
limit)))
|
||||||
|
|
||||||
(defun org-fold-core-previous-folding-state-change (&optional spec-or-alias pos limit)
|
(defun org-fold-core-previous-folding-state-change (&optional spec-or-alias pos limit)
|
||||||
"Call `org-fold-core-next-folding-state-change' searching backwards."
|
"Call `org-fold-core-next-folding-state-change' searching backwards."
|
||||||
|
|
Loading…
Reference in a new issue