branch: elpa/git-commit commit 4ec4d0272e6c50f10ccc96350ed917a3e8d3313a Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
magit-insert-section--finish: Optimize propertizing leaf sections --- lisp/magit-section.el | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lisp/magit-section.el b/lisp/magit-section.el index b0c6c4ac06..b29a65f046 100644 --- a/lisp/magit-section.el +++ b/lisp/magit-section.el @@ -1447,19 +1447,22 @@ anything this time around. (point-marker)))) (props `( magit-section ,obj ,@(and-let* ((map (symbol-value (oref obj keymap)))) - (list 'keymap map))))) + (list 'keymap map)))) + (children (oref obj children))) (unless magit-section-inhibit-markers (set-marker-insertion-type beg t)) - (save-excursion - (goto-char beg) - (while (< (point) end) - (let ((next (or (next-single-property-change - (point) 'magit-section) - end))) - (unless (magit-section-at) - (add-text-properties (point) next props)) - (magit-section-maybe-add-heading-map obj) - (goto-char next)))) + (cond (children + (save-excursion + (goto-char beg) + (while (< (point) end) + (let ((next (or (next-single-property-change + (point) 'magit-section) + end))) + (unless (magit-section-at) + (add-text-properties (point) next props)) + (magit-section-maybe-add-heading-map obj) + (goto-char next))))) + ((add-text-properties beg end props))) (cond ((eq obj magit-root-section) (when (eq magit-section-inhibit-markers 'delay) (setq magit-section-inhibit-markers nil) @@ -1476,7 +1479,7 @@ anything this time around. (list obj)))))) (when magit-section-insert-in-reverse (setq magit-section-insert-in-reverse nil) - (oset obj children (nreverse (oref obj children)))))) + (oset obj children (nreverse children))))) (defun magit-cancel-section (&optional if-empty) "Cancel inserting the section that is currently being inserted.