1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-01 08:17:34 +00:00

org-element--cache-active-p: Improve performance

* lisp/org-element.el (org-element--cache-active-p): Remove expensive
`derived-mode-p' call.  Reshuffle the conditions to avoid costly
`memq' call as much as possible.  Inline the function.
This commit is contained in:
Ihor Radchenko 2022-09-21 12:22:35 +08:00
parent f1a197401c
commit 7e9d927298
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B

View File

@ -5679,12 +5679,12 @@ This function assumes `org-element--headline-cache' is a valid AVL tree."
;;;; Tools
(defun org-element--cache-active-p (&optional called-from-cache-change-func-p)
(defsubst org-element--cache-active-p (&optional called-from-cache-change-func-p)
"Non-nil when cache is active in current buffer."
(and org-element-use-cache
org-element--cache
(derived-mode-p 'org-mode)
(or called-from-cache-change-func-p
(eq org-element--cache-change-tic (buffer-chars-modified-tick))
(and
;; org-num-mode calls some Org structure analysis functions
;; that can trigger cache update in the middle of changes. See
@ -5699,8 +5699,7 @@ This function assumes `org-element--headline-cache' is a valid AVL tree."
;; `combine-change-calls' because the buffer is potentially
;; changed without notice (the change will be registered
;; after exiting the `combine-change-calls' body though).
(memq #'org-element--cache-after-change after-change-functions))
(eq org-element--cache-change-tic (buffer-chars-modified-tick)))))
(memq #'org-element--cache-after-change after-change-functions)))))
;; FIXME: Remove after we establish that hashing is effective.
(defun org-element-cache-hash-show-statistics ()