emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#71604: closed (diff--get-revision-properties calls set-auto-mode twi


From: GNU bug Tracking System
Subject: bug#71604: closed (diff--get-revision-properties calls set-auto-mode twice)
Date: Mon, 17 Jun 2024 20:02:02 +0000

Your message dated Mon, 17 Jun 2024 23:01:34 +0300
with message-id <e13c882d-61d6-453f-a7e7-4b77872be2a6@gutov.dev>
and subject line Re: bug#71604: diff--get-revision-properties calls 
set-auto-mode twice
has caused the debbugs.gnu.org bug report #71604,
regarding diff--get-revision-properties calls set-auto-mode twice
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
71604: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71604
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: diff--get-revision-properties calls set-auto-mode twice Date: Mon, 17 Jun 2024 05:25:31 +0300 User-agent: Mozilla Thunderbird
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.



--- End Message ---
--- Begin Message --- Subject: Re: bug#71604: diff--get-revision-properties calls set-auto-mode twice Date: Mon, 17 Jun 2024 23:01:34 +0300 User-agent: Mozilla Thunderbird
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.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]