From: Philip Kaludercic <philipk@posteo.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] Speed up project-kill-buffers
Date: Mon, 03 May 2021 13:06:35 +0000 [thread overview]
Message-ID: <871raoezl0.fsf@posteo.net> (raw)
In-Reply-To: <jwv1raovvcw.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 03 May 2021 08:46:08 -0400")
[-- Attachment #1: Type: text/plain, Size: 1016 bytes --]
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> (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)))
>
> How 'bout using `file-in-directory-p`?
I didn't know about that function! Just tried it out and it seems that
the patch below is even faster, as project-current does not have to be
invoked for every buffer, remote or not.
> Stefan
>
--
Philip K.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Reduce-number-of-method-invocations-in-project-buffe.patch --]
[-- Type: text/x-diff, Size: 1136 bytes --]
From eb9f32e1007eaa90a1b5487ac009b38182d6260b Mon Sep 17 00:00:00 2001
From: Philip K <philipk@posteo.net>
Date: Mon, 3 May 2021 11:35:41 +0200
Subject: [PATCH] Reduce number of method invocations in project--buffer-list
* project.el (project--buffer-list): Use file-in-directory-p
---
lisp/progmodes/project.el | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index d47d9d77e6..aa2fc1690f 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1120,11 +1120,12 @@ project-kill-buffer-conditions
(defun project--buffer-list (pr)
"Return the list of all buffers in project PR."
- (let (bufs)
+ (let ((root (project-root pr))
+ bufs)
(dolist (buf (buffer-list))
- (when (equal pr
- (with-current-buffer buf
- (project-current)))
+ (when-let ((file (or (buffer-file-name buf)
+ (buffer-local-value 'default-directory buf)))
+ ((file-in-directory-p file root)))
(push buf bufs)))
(nreverse bufs)))
--
2.30.2
next prev parent reply other threads:[~2021-05-03 13:06 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-03 9:43 [PATCH] Speed up project-kill-buffers Philip Kaludercic
2021-05-03 12:46 ` Stefan Monnier
2021-05-03 13:06 ` Philip Kaludercic [this message]
2021-05-03 13:24 ` Stefan Monnier
2021-05-03 17:25 ` Philip Kaludercic
2021-05-03 21:12 ` Dmitry Gutov
2021-05-08 12:03 ` Stephen Leake
2021-05-08 12:30 ` Philip Kaludercic
2021-05-08 13:05 ` Philip Kaludercic
2021-05-08 17:01 ` Dmitry Gutov
2021-05-08 17:10 ` Dmitry Gutov
2021-05-16 20:36 ` Stephen Leake
2021-05-16 21:58 ` Dmitry Gutov
2021-05-19 23:37 ` Stephen Leake
2021-05-20 12:16 ` Stephen Leake
2021-05-25 1:30 ` Dmitry Gutov
2021-05-30 17:19 ` Stephen Leake
2021-05-25 1:24 ` Dmitry Gutov
2021-05-30 17:51 ` Stephen Leake
2021-08-09 3:01 ` Dmitry Gutov
2021-05-03 21:43 ` Dmitry Gutov
2021-05-03 22:45 ` Stefan Monnier
2021-05-03 22:46 ` Dmitry Gutov
2021-05-04 6:25 ` tomas
2021-05-04 10:40 ` Dmitry Gutov
2021-05-04 11:26 ` tomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871raoezl0.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.