all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#71604: diff--get-revision-properties calls set-auto-mode twice
@ 2024-06-17  2:25 Dmitry Gutov
  2024-06-17 16:33 ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Gutov @ 2024-06-17  2:25 UTC (permalink / raw)
  To: 71604; +Cc: juri linkov

X-Debbugs-Cc: Juri Linkov <juri@linkov.net>
Tags: patch

vc-find-revision-no-save calls set-auto-mode, and then we repeat that 
call in diff-syntax-fontify-props.

Which is a problem with CC Mode because it parses the buffer inside the 
major mode function, and ends up doing that twice, at least the first 
time the buffer is initialized before being saved to revision cache. Not 
exactly double the work, but more work nevertheless.

This is a split off from https://debbugs.gnu.org/61667#587. I thought I 
recalled an existing report of vc-diff being slow, but apparently not.

diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index c0269d882b9..cc5509ca347 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -2883,9 +2883,6 @@ diff--get-revision-properties
           (buffer (cdr entry)))
      (if (buffer-live-p buffer)
          (progn
-          ;; Don't re-initialize the buffer (which would throw
-          ;; away the previous fontification work).
-          (setq file nil)
            (setq diff--cached-revision-buffers
                  (cons entry
                        (delq entry diff--cached-revision-buffers))))
@@ -2905,7 +2902,8 @@ diff--get-revision-properties
      (diff--cache-schedule-clean)
      (and buffer
           (with-current-buffer buffer
-           (diff-syntax-fontify-props file text line-nb)))))
+           ;; major mode is set in vc-find-revision-no-save already.
+           (diff-syntax-fontify-props nil text line-nb)))))

  (defun diff-syntax-fontify-hunk (beg end old)
    "Highlight source language syntax in diff hunk between BEG and END.





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#71604: diff--get-revision-properties calls set-auto-mode twice
  2024-06-17  2:25 bug#71604: diff--get-revision-properties calls set-auto-mode twice Dmitry Gutov
@ 2024-06-17 16:33 ` Juri Linkov
  2024-06-17 20:01   ` Dmitry Gutov
  0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2024-06-17 16:33 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 71604

> vc-find-revision-no-save calls set-auto-mode, and then we repeat that call
> in diff-syntax-fontify-props.
>
> Which is a problem with CC Mode because it parses the buffer inside the
> major mode function, and ends up doing that twice, at least the first time
> the buffer is initialized before being saved to revision cache. Not exactly
> double the work, but more work nevertheless.
>
> This is a split off from https://debbugs.gnu.org/61667#587. I thought
> I recalled an existing report of vc-diff being slow, but apparently not.
>
> @@ -2883,9 +2883,6 @@ diff--get-revision-properties
>           (buffer (cdr entry)))
>      (if (buffer-live-p buffer)
>          (progn
> -          ;; Don't re-initialize the buffer (which would throw
> -          ;; away the previous fontification work).
> -          (setq file nil)
>            (setq diff--cached-revision-buffers
>                  (cons entry
>                        (delq entry diff--cached-revision-buffers))))
> @@ -2905,7 +2902,8 @@ diff--get-revision-properties
>      (diff--cache-schedule-clean)
>      (and buffer
>           (with-current-buffer buffer
> -           (diff-syntax-fontify-props file text line-nb)))))
> +           ;; major mode is set in vc-find-revision-no-save already.
> +           (diff-syntax-fontify-props nil text line-nb)))))

Thanks, looks correct.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#71604: diff--get-revision-properties calls set-auto-mode twice
  2024-06-17 16:33 ` Juri Linkov
@ 2024-06-17 20:01   ` Dmitry Gutov
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Gutov @ 2024-06-17 20:01 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 71604-done

On 17/06/2024 19:33, Juri Linkov wrote:
>> vc-find-revision-no-save calls set-auto-mode, and then we repeat that call
>> in diff-syntax-fontify-props.
>>
>> Which is a problem with CC Mode because it parses the buffer inside the
>> major mode function, and ends up doing that twice, at least the first time
>> the buffer is initialized before being saved to revision cache. Not exactly
>> double the work, but more work nevertheless.
>>
>> This is a split off from https://debbugs.gnu.org/61667#587. I thought
>> I recalled an existing report of vc-diff being slow, but apparently not.
>>
>> @@ -2883,9 +2883,6 @@ diff--get-revision-properties
>>            (buffer (cdr entry)))
>>       (if (buffer-live-p buffer)
>>           (progn
>> -          ;; Don't re-initialize the buffer (which would throw
>> -          ;; away the previous fontification work).
>> -          (setq file nil)
>>             (setq diff--cached-revision-buffers
>>                   (cons entry
>>                         (delq entry diff--cached-revision-buffers))))
>> @@ -2905,7 +2902,8 @@ diff--get-revision-properties
>>       (diff--cache-schedule-clean)
>>       (and buffer
>>            (with-current-buffer buffer
>> -           (diff-syntax-fontify-props file text line-nb)))))
>> +           ;; major mode is set in vc-find-revision-no-save already.
>> +           (diff-syntax-fontify-props nil text line-nb)))))
> 
> Thanks, looks correct.

Pushed to master, thanks.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-17 20:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-17  2:25 bug#71604: diff--get-revision-properties calls set-auto-mode twice Dmitry Gutov
2024-06-17 16:33 ` Juri Linkov
2024-06-17 20:01   ` Dmitry Gutov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.