mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 12:31:25 +00:00
diff-mode.el: Don't recompute the position of Git preamble/footer
On some profiles (after disabling syntax and refined fontification), this was taking >90% of the time to fontify a buffer. * lisp/vc/diff-mode.el (diff--git-preamble-overlay) (diff--git-footer-overlay): New variables. (diff--git-preamble-end, diff--git-footer-start): Use them to cache the result.
This commit is contained in:
parent
32e8989157
commit
43304ea735
1 changed files with 29 additions and 9 deletions
|
|
@ -535,18 +535,38 @@ use the face `diff-removed' for removed lines, and the face
|
||||||
(group (any "<-"))
|
(group (any "<-"))
|
||||||
(group (zero-or-more nonl) "\n")))
|
(group (zero-or-more nonl) "\n")))
|
||||||
|
|
||||||
|
(defvar-local diff--git-preamble-overlay nil)
|
||||||
|
(defvar-local diff--git-footer-overlay nil)
|
||||||
|
|
||||||
(defun diff--git-preamble-end ()
|
(defun diff--git-preamble-end ()
|
||||||
(save-excursion
|
(unless (and diff--git-preamble-overlay
|
||||||
(goto-char (point-min))
|
(overlay-buffer diff--git-preamble-overlay))
|
||||||
(re-search-forward "^diff --git .+ .+$" nil t)
|
(save-excursion
|
||||||
(forward-line 2)
|
(goto-char (point-min))
|
||||||
(point)))
|
(re-search-forward "^diff --git .+ .+$" nil t)
|
||||||
|
(forward-line 2)
|
||||||
|
(if diff--git-preamble-overlay
|
||||||
|
(move-overlay diff--git-preamble-overlay (point-min) (point))
|
||||||
|
(let ((ol (make-overlay (point-min) (point))))
|
||||||
|
(overlay-put ol 'modification-hooks (lambda (&rest _) (delete-overlay ol)))
|
||||||
|
(overlay-put ol 'evaporate t)
|
||||||
|
(setq diff--git-preamble-overlay ol)))))
|
||||||
|
(overlay-end diff--git-preamble-overlay))
|
||||||
|
|
||||||
(defun diff--git-footer-start ()
|
(defun diff--git-footer-start ()
|
||||||
(save-excursion
|
(unless (and diff--git-footer-overlay
|
||||||
(goto-char (point-max))
|
(overlay-buffer diff--git-footer-overlay))
|
||||||
(re-search-backward "^-- $" nil t)
|
(save-excursion
|
||||||
(point)))
|
(goto-char (point-max))
|
||||||
|
(re-search-backward "\n-- $" nil t)
|
||||||
|
(if diff--git-footer-overlay
|
||||||
|
(move-overlay diff--git-footer-overlay
|
||||||
|
(match-beginning 0) (point-max))
|
||||||
|
(let ((ol (make-overlay (match-beginning 0) (point-max) nil t t)))
|
||||||
|
(overlay-put ol 'modification-hooks (lambda (&rest _) (delete-overlay ol)))
|
||||||
|
(overlay-put ol 'evaporate t)
|
||||||
|
(setq diff--git-footer-overlay ol)))))
|
||||||
|
(1+ (overlay-start diff--git-footer-overlay)))
|
||||||
|
|
||||||
(defun diff--indicator-matcher-helper (limit regexp)
|
(defun diff--indicator-matcher-helper (limit regexp)
|
||||||
"Fontify added/removed lines from point to LIMIT using REGEXP.
|
"Fontify added/removed lines from point to LIMIT using REGEXP.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue