From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: [PATCH] Speed up project-kill-buffers Date: Mon, 03 May 2021 11:43:13 +0200 Message-ID: <87mttcgnke.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27210"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: emacs-devel@gnu.org Cancel-Lock: sha1:uh7CggIrGoxzS1cIT0vaKPtQCvo= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon May 03 11:44:07 2021 Return-path: Envelope-to: ged-emacs-devel@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 1ldV7V-0006y9-Oz for ged-emacs-devel@m.gmane-mx.org; Mon, 03 May 2021 11:44:05 +0200 Original-Received: from localhost ([::1]:42556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldV7U-0005Va-RG for ged-emacs-devel@m.gmane-mx.org; Mon, 03 May 2021 05:44:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldV6o-0004JF-Ke for emacs-devel@gnu.org; Mon, 03 May 2021 05:43:22 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]:43702) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldV6m-00068W-SL for emacs-devel@gnu.org; Mon, 03 May 2021 05:43:22 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1ldV6k-0006Bz-0p for emacs-devel@gnu.org; Mon, 03 May 2021 11:43:18 +0200 X-Injected-Via-Gmane: http://gmane.org/ Autocrypt: addr=philipk@posteo.net; prefer-encrypt=mutual; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:268804 Archived-At: --=-=-= Content-Type: text/plain Hi, I've noticed that sometimes project-kill-buffers is noticeably slow, and it seems like it's has to do with project--buffer-list working on remote files. The function goes through every buffer and calls (project-current), even if the buffer is related to a remote file that cannot be part of the current project. The patch I attach below is a simple fix to avoid checking files that cannot be part of the current project. Or are there any edge-cases that this code approach breaks? -- Philip K. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Avoid-Tramp-buffers-when-possible.patch >From 8b45502da8281826fa2da02a317546bc99f51069 Mon Sep 17 00:00:00 2001 From: Philip K Date: Mon, 3 May 2021 11:35:41 +0200 Subject: [PATCH] Avoid Tramp buffers when possible * project.el (project--buffer-list): Add file-remote-p check --- lisp/progmodes/project.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index d47d9d77e6..33827136a1 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1120,11 +1120,14 @@ project-kill-buffer-conditions (defun project--buffer-list (pr) "Return the list of all buffers in project PR." - (let (bufs) + (let ((remote-project-p (file-remote-p (project-root pr))) + bufs) (dolist (buf (buffer-list)) - (when (equal pr - (with-current-buffer buf - (project-current))) + (when (and (let ((remote (file-remote-p (buffer-local-value 'default-directory buf)))) + (if remote-project-p remote (not remote))) + (equal pr + (with-current-buffer buf + (project-current)))) (push buf bufs))) (nreverse bufs))) -- 2.30.2 --=-=-=--