From 4254a54f88fde682d6a6d255b7960d20b25ff126 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Mon, 5 Feb 2024 22:12:03 +0100 Subject: [PATCH] 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. --- lisp/org.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index a728f485d..da315fccb 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -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))))))