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

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

bug#59935: 29.0.60; project-list-buffers is slow


From: Dmitry Gutov
Subject: bug#59935: 29.0.60; project-list-buffers is slow
Date: Sat, 10 Dec 2022 03:49:47 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

X-Debbugs-Cc: juri@linkov.net

When you invoke 'C-x p C-b', there's a noticeable pause before the
buffer list is displayed. It's ~400ms over here when there are 46
non-hidden buffers in the running session.

What I think is happening, the predicate is called 46, which in turn calls (project-buffers pr) 46 times, and that ends up being 46 times slower than one might have anticipated.

Not sure what's the best fix here (especially in time for the release),
but if the FILTER-PREDICATE arg to list-buffers-noselect turned into a
factory function (e.g. FILTER-PREDICATE-MAKER), that would be one
solution.

Another would be to only leave the legacy codepath: it's not affected,
project-buffers is only called once there.

Curiously, though, it shows a different list of buffers. It also
includes "hidden" buffers - diff-syntax, Echo Area, etc. We should look
into that either way.

And the patch is this:

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 016dfdd5b4..ad49df0423 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1342,16 +1342,13 @@ project-list-buffers
   (interactive "P")
   (let ((pr (project-current t)))
     (display-buffer
-     (if (version< emacs-version "29.0.50")
-         (let ((buf (list-buffers-noselect arg (project-buffers pr))))
-           (with-current-buffer buf
-             (setq-local revert-buffer-function
-                         (lambda (&rest _ignored)
-                           (list-buffers--refresh (project-buffers pr))
-                           (tabulated-list-print t))))
-           buf)
-       (list-buffers-noselect
-        arg nil (lambda (buf) (memq buf (project-buffers pr))))))))
+     (let ((buf (list-buffers-noselect arg (project-buffers pr))))
+       (with-current-buffer buf
+         (setq-local revert-buffer-function
+                     (lambda (&rest _ignored)
+                       (list-buffers--refresh (project-buffers pr))
+                       (tabulated-list-print t))))
+       buf))))
  (defcustom project-kill-buffer-conditions
   '(buffer-file-name    ; All file-visiting buffers are included.





reply via email to

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