Maxim Nikulin <maniku...@gmail.com> writes: > Curiously my experience is that avoiding this lazy cache with > backtracking and maintaining custom structure during sequential scan of > the buffer works several times faster.
My experience is exactly opposite. Or maybe I miss something. Can you elaborate? > ... However it is appropriate time to > populate the cache you mentioned. Unfortunately it is still necessary to > cleanup heading text, and it consumes significant time. Did you do any benchmarks? I just tried Outline path without cache: (benchmark-run 1 (goto-char (point-min)) (while (re-search-forward "^\\*+" nil t) (org-get-outline-path t nil))) => (6.051079914 1 0.2864724879999869) Outline path with cache: (benchmark-run 1 (goto-char (point-min)) (while (re-search-forward "^\\*+" nil t) (org-get-outline-path t nil))) => (1.658461165 0 0.0) Just cleanup heading text: (benchmark-run 1 (goto-char (point-min)) (while (re-search-forward "^\\*+" nil t) (let ((case-fold-search nil)) (looking-at org-complex-heading-regexp) (if (not (match-end 4)) "" ;; Remove statistics cookies. (org-trim (org-link-display-format (replace-regexp-in-string "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" "" (match-string-no-properties 4)))))))) => (0.013364877 0 0.0) Best, Ihor