org-update-parent-todo-statistics: Do not modify buffer unnecessarily

* lisp/org.el (org-update-parent-todo-statistics): When the updated
statistics cookie is unchanged, do not modify buffer.  This prevents
unnecessary queries to element cache.
This commit is contained in:
Ihor Radchenko 2024-02-05 22:12:03 +01:00
parent 10d2868c58
commit 4254a54f88
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 5 additions and 4 deletions

View File

@ -9829,10 +9829,11 @@ statistics everywhere."
(max 1 cnt-all)))
(format "[%d/%d]" cnt-done cnt-all))
ndel (- (match-end 0) checkbox-beg))
(goto-char checkbox-beg)
(insert new)
(delete-region (point) (+ (point) ndel))
(when org-auto-align-tags (org-fix-tags-on-the-fly))))
(unless (string-equal new (buffer-substring checkbox-beg (match-end 0)))
(goto-char checkbox-beg)
(insert new)
(delete-region (point) (+ (point) ndel))
(when org-auto-align-tags (org-fix-tags-on-the-fly)))))
(when cookie-present
(run-hook-with-args 'org-after-todo-statistics-hook
cnt-done (- cnt-all cnt-done))))))