From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#71604: diff--get-revision-properties calls set-auto-mode twice Date: Mon, 17 Jun 2024 19:33:03 +0300 Organization: LINKOV.NET Message-ID: <865xu7zg6o.fsf@mail.linkov.net> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31573"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 71604@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 17 18:35:19 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sJFKA-0007xU-LS for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Jun 2024 18:35:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJFJu-00021p-9R; Mon, 17 Jun 2024 12:35:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJFJs-000219-MI for bug-gnu-emacs@gnu.org; Mon, 17 Jun 2024 12:35:00 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJFJs-0005IX-EG for bug-gnu-emacs@gnu.org; Mon, 17 Jun 2024 12:35:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sJFJu-0002Yi-Fi for bug-gnu-emacs@gnu.org; Mon, 17 Jun 2024 12:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Jun 2024 16:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71604 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 71604-submit@debbugs.gnu.org id=B71604.17186420769774 (code B ref 71604); Mon, 17 Jun 2024 16:35:02 +0000 Original-Received: (at 71604) by debbugs.gnu.org; 17 Jun 2024 16:34:36 +0000 Original-Received: from localhost ([127.0.0.1]:35232 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJFJU-0002XZ-94 for submit@debbugs.gnu.org; Mon, 17 Jun 2024 12:34:36 -0400 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:37755) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJFJR-0002XL-Fm for 71604@debbugs.gnu.org; Mon, 17 Jun 2024 12:34:35 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 43E6AE0003; Mon, 17 Jun 2024 16:34:20 +0000 (UTC) In-Reply-To: (Dmitry Gutov's message of "Mon, 17 Jun 2024 05:25:31 +0300") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:287406 Archived-At: > 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.