branch: elpa/projectile
commit e0eda06495826cbb9ada9ced4f304ee9caf1916f
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>

    Share truename cache across buffers in projectile-open-projects
    
    Like projectile-project-buffers, pass a shared truename-cache hash
    table to projectile-project-buffer-p to avoid redundant
    file-truename calls when iterating over the buffer list.
---
 projectile.el | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/projectile.el b/projectile.el
index 5b2c84e1a2..e7f84bf20e 100644
--- a/projectile.el
+++ b/projectile.el
@@ -5685,15 +5685,16 @@ directories."
 (defun projectile-open-projects ()
   "Return a list of all open projects.
 An open project is a project with any open buffers."
-  (seq-uniq
-   ;; TODO: Replace delq+mapcar with seq-keep when Emacs 29.1 is the minimum 
version
-   (delq nil
-         (mapcar (lambda (buffer)
-                   (with-current-buffer buffer
-                     (when-let* ((project-root (projectile-project-root)))
-                       (when (projectile-project-buffer-p buffer project-root)
-                         (abbreviate-file-name project-root)))))
-                 (buffer-list)))))
+  (let ((truename-cache (make-hash-table :test 'equal)))
+    (seq-uniq
+     ;; TODO: Replace delq+mapcar with seq-keep when Emacs 29.1 is the minimum 
version
+     (delq nil
+           (mapcar (lambda (buffer)
+                     (with-current-buffer buffer
+                       (when-let* ((project-root (projectile-project-root)))
+                         (when (projectile-project-buffer-p buffer 
project-root truename-cache)
+                           (abbreviate-file-name project-root)))))
+                   (buffer-list))))))
 
 (defun projectile--remove-current-project (projects)
   "Remove the current project (if any) from the list of PROJECTS."

Reply via email to