mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-25 05:32:51 +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
|
||||
(setq spec-or-alias (org-fold-core-folding-spec-list)))
|
||||
(setq pos (or pos (point)))
|
||||
(apply (if previous-p
|
||||
#'max
|
||||
#'min)
|
||||
(mapcar (if previous-p
|
||||
(lambda (prop) (max (or limit (point-min)) (previous-single-char-property-change pos prop nil (or limit (point-min)))))
|
||||
(lambda (prop) (next-single-char-property-change pos prop nil (or limit (point-max)))))
|
||||
(mapcar (lambda (el) (org-fold-core--property-symbol-get-create el nil t))
|
||||
spec-or-alias))))
|
||||
(let ((limit (or limit (if previous-p (point-min) (point-max)))))
|
||||
(catch :limit
|
||||
(dolist (prop (mapcar
|
||||
(lambda (el)
|
||||
(org-fold-core--property-symbol-get-create el nil t))
|
||||
spec-or-alias))
|
||||
(when (= limit pos) (throw :limit limit))
|
||||
(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)
|
||||
"Call `org-fold-core-next-folding-state-change' searching backwards."
|
||||
|
|
Loading…
Reference in a new issue