Open
Description
Hello 👋
On my system, running counsel-projectile-switch-project with the find-file action is much slower that calling counsel-projectile-find-file directly. This issue may be related to #153.
I used etrace to inspect function calls when running counsel-projectile-switch-project with the find-file action, and found that counsel-projectile--project-buffers-and-files
is called a lot (22 times during my test).
As a quick test, I applied the patch below. With that change, counsel-projectile-switch-project is as fast as calling counsel-projectile-find-file directly.
diff --git a/counsel-projectile.el b/counsel-projectile.el
index 81b6b01..72e6944 100644
--- a/counsel-projectile.el
+++ b/counsel-projectile.el
@@ -1625,17 +1625,18 @@ candidate non-visited file."
(not (projectile-project-p)))
(counsel-projectile-action-switch-project)
(projectile-maybe-invalidate-cache arg)
- (ivy-read (projectile-prepend-project-name "Load buffer or file: ")
+ (let ((buffers-and-files (counsel-projectile--project-buffers-and-files)))
+ (ivy-read (projectile-prepend-project-name "Load buffer or file: ")
;; We use a collection function so that it is called each
;; time the `ivy-state' is reset. This is needed for the
;; "kill buffer" action.
- #'counsel-projectile--project-buffers-and-files
+ buffers-and-files
:matcher #'counsel-projectile--matcher
:require-match t
:action counsel-projectile-action
:keymap counsel-projectile-map
:extra-props (list :from-buffer from-buffer)
- :caller 'counsel-projectile)))
+ :caller 'counsel-projectile))))
(ivy-configure 'counsel-projectile
:display-transformer-fn #'counsel-projectile-transformer
--
I'm sure there are edge cases that make it so that this cannot be applied directly but hopefully it can help :)
Metadata
Metadata
Assignees
Labels
No labels