From unknown Tue Aug 19 05:09:05 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#71604 <71604@debbugs.gnu.org> To: bug#71604 <71604@debbugs.gnu.org> Subject: Status: diff--get-revision-properties calls set-auto-mode twice Reply-To: bug#71604 <71604@debbugs.gnu.org> Date: Tue, 19 Aug 2025 12:09:05 +0000 retitle 71604 diff--get-revision-properties calls set-auto-mode twice reassign 71604 emacs submitter 71604 Dmitry Gutov severity 71604 normal tag 71604 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 16 22:25:41 2024 Received: (at submit) by debbugs.gnu.org; 17 Jun 2024 02:25:41 +0000 Received: from localhost ([127.0.0.1]:58348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJ23x-0001bR-AW for submit@debbugs.gnu.org; Sun, 16 Jun 2024 22:25:41 -0400 Received: from lists.gnu.org ([209.51.188.17]:44674) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJ23v-0001bH-L1 for submit@debbugs.gnu.org; Sun, 16 Jun 2024 22:25:40 -0400 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 1sJ23s-0001zD-Tn for bug-gnu-emacs@gnu.org; Sun, 16 Jun 2024 22:25:37 -0400 Received: from fout3-smtp.messagingengine.com ([103.168.172.146]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJ23q-0003qJ-Q7 for bug-gnu-emacs@gnu.org; Sun, 16 Jun 2024 22:25:36 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.nyi.internal (Postfix) with ESMTP id DD2DF13801AF for ; Sun, 16 Jun 2024 22:25:33 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 16 Jun 2024 22:25:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to; s=fm3; t=1718591133; x=1718677533; bh=8rLyh07CQP IDPwsGTboMotdbftbg9DEBC7bCBpmTV2g=; b=jnejPDry4By8XOXUc4fXeikosz E9JcAO+L1rOHUFV/Hj4D4TuQVRD+KoVmrrbWLd4N39EoEG9snY4aAa2ZGnfxb44Q 8fpEB9vggawe8rAR8Bn6WT0R30pC0BIv8PiVoNBHAYV/XfcY9Ch0HzqdBuLo6X3z JySt0WbFYIDg4AW6pSt4ds43KwuzNVOw6px86sEkgoit77AUUg7Lds8NIidEM0a7 hy+RePpxBosOKzMAhL+0pGxHSejJIIUWBn7NcDXgq23GXMSAzY23iFyhYwINlzMQ zGMG6ZXdVLHRaMZrHtiaL9LvNc1qsSLLN8Kn19hj3XYAthiiYqTwYiFOn4yg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1718591133; x=1718677533; bh=8rLyh07CQPIDPwsGTboMotdbftbg 9DEBC7bCBpmTV2g=; b=HNjt0m2gX4fyTqXn7ps+AQdnTvjFv9IphvzpYQHr2XFC veAGgzmldLKRRqUI/WOGBEPXZ4mEjEMxNoAunbf2FBodinuiURB6SKVqr+Bouh7/ 1PJm8bdFIiq4/30zepKF7aTHUQo52tswpApFjv5sJV2PiCF9bBZ2FVerXJFo+lKi fnNxOsCtGmzrz+RCksBkQzfYLTLqnjEXmSq0p8yQ3pjRYxUSTlEJEudswbjjhjp6 SAQGDttYMwJoL7e7WfYm20fnMOwkVImh35/e5n5DPTLP8K1fh4BsdcOPdmYUiLKj LwGc1sBP+BdlyzcMV6O5R8v2SmARyPT5nk5vHC0VJQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedvgedgheelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfvhffutgfgsehtjeertd dtvdejnecuhfhrohhmpeffmhhithhrhicuifhuthhovhcuoegumhhithhrhiesghhuthho vhdruggvvheqnecuggftrfgrthhtvghrnhepgefgjedvueekkeduffekgedutefhkeevgf egkeehgeduffdulefhfefhteetledvnecuffhomhgrihhnpehgnhhurdhorhhgnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepughmihhtrhihse hguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sun, 16 Jun 2024 22:25:33 -0400 (EDT) Message-ID: Date: Mon, 17 Jun 2024 05:25:31 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: bug-gnu-emacs@gnu.org From: Dmitry Gutov Subject: diff--get-revision-properties calls set-auto-mode twice Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=103.168.172.146; envelope-from=dmitry@gutov.dev; helo=fout3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.7 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.7 (--) X-Debbugs-Cc: Juri Linkov 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. From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 17 12:34:36 2024 Received: (at 71604) by debbugs.gnu.org; 17 Jun 2024 16:34:36 +0000 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 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 Received: by mail.gandi.net (Postfix) with ESMTPSA id 43E6AE0003; Mon, 17 Jun 2024 16:34:20 +0000 (UTC) From: Juri Linkov To: Dmitry Gutov Subject: Re: bug#71604: diff--get-revision-properties calls set-auto-mode twice In-Reply-To: (Dmitry Gutov's message of "Mon, 17 Jun 2024 05:25:31 +0300") Organization: LINKOV.NET References: Date: Mon, 17 Jun 2024 19:33:03 +0300 Message-ID: <865xu7zg6o.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 71604 Cc: 71604@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > 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. From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 17 16:01:49 2024 Received: (at 71604-done) by debbugs.gnu.org; 17 Jun 2024 20:01:50 +0000 Received: from localhost ([127.0.0.1]:36556 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJIY1-0002Yr-JB for submit@debbugs.gnu.org; Mon, 17 Jun 2024 16:01:49 -0400 Received: from wfout4-smtp.messagingengine.com ([64.147.123.147]:57975) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJIXy-0002Ya-QN for 71604-done@debbugs.gnu.org; Mon, 17 Jun 2024 16:01:47 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.west.internal (Postfix) with ESMTP id 72E621C00101; Mon, 17 Jun 2024 16:01:38 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 17 Jun 2024 16:01:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1718654498; x=1718740898; bh=MYY8atP1AV1Q0OD20MKcdZEgBKK7egZEepV48qnUmTI=; b= WaGXk0gQSDZQGprXaO9Sp7Jggf0jLmfnjIsiKRieKnyVQ9z/Wq3OoYCT3Cq61AGq 0NKACVOcJgrMLNtkV7NkYc2kIEbYYzBeRVmmDWrWqeDGEATVVphNTt56439o1+N0 FFMOWgJTXzpQl5W/0apd33CX4x1Oj9oCPvyggk9YfnyQ4MQaosBv6Gyx8WCsxcNQ qvY7rvP9WTeh4k7vV5NA4oDGkKr9aTfmTe26VAswaKmBmHOBvmNED9LJOuX8kegV ZXrmo35/u8JmTgr/Fq9ZsQu/Ild//mX4bSSjsfU/W38q9/MIQqLibbofDb6Ll+Ma fWlgkOuPYVa1rPdG1wtr4g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1718654498; x= 1718740898; bh=MYY8atP1AV1Q0OD20MKcdZEgBKK7egZEepV48qnUmTI=; b=p vZyLGunLa/X74ouJnRfve4y7LcXw+ARgDRxPMUcI9TiD+U9/qeKL7LPWJ4nLIdYA 1RSObagQtF8KL4dtlDhmejGHD3J7P5z/Shk12mhG7n2MlBtvuJ/5A+lHUMl7IQut RbHGGz/88jzi2ovxber60sCmGr0LDpyq879SMavPqPDEdBYEESfLdclcG3VpQ1qY vuhyUrtV+ld8kbac3mQA8iyPXc6J+meVX3MRJyuL4tiidgNReRU8Pl0MPEs4+qnJ 0R9JP6D+D4syMQ7rLgcqB5diAYjQsuDGTEFqSIvKQrWrFSHlNU+4X7DWKsOgnIhQ DA0PbC3hC1qkyRb+FZV3w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedvhedgudeggecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeenucfhrhhomhepffhm ihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrg htthgvrhhnpeffieefvdelueektdfgleeigedugfevkeefjeevjeffteffueeuueeghfev ieduvdenucffohhmrghinhepghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 17 Jun 2024 16:01:36 -0400 (EDT) Message-ID: Date: Mon, 17 Jun 2024 23:01:34 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#71604: diff--get-revision-properties calls set-auto-mode twice To: Juri Linkov References: <865xu7zg6o.fsf@mail.linkov.net> Content-Language: en-US From: Dmitry Gutov In-Reply-To: <865xu7zg6o.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 71604-done Cc: 71604-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) 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. From unknown Tue Aug 19 05:09:05 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 16 Jul 2024 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator