Skip to content

Commit 55e9026

Browse files
authored
Optimize compilation-find-file-projectile-find-compilation-buffer (#1874)
If the target file already exists, navigate to it directly instead of running the expensive extra logic.
1 parent 874ccb3 commit 55e9026

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### New features
66

7+
* [#1874](https://github.com/bbatsov/projectile/pull/1874): Changes `compilation-find-file-projectile-find-compilation-buffer` to navigate directly to the file if already present on disk to help improve performance in scenarios where there are a large number of project directories.
78
* [#1870](https://github.com/bbatsov/projectile/pull/1870): Add package command for CMake projects.
89
* [#1875](https://github.com/bbatsov/projectile/pull/1875): Add support for Sapling VCS.
910
* [#1876](https://github.com/bbatsov/projectile/pull/1876): Add support for Jujutsu VCS.

projectile.el

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5406,14 +5406,18 @@ We enhance its functionality by appending the current project's directories
54065406
to its search path. This way when filenames in compilation buffers can't be
54075407
found by compilation's normal logic they are searched for in project
54085408
directories."
5409-
(let* ((root (projectile-project-root))
5410-
(compilation-search-path
5411-
(if (projectile-project-p)
5412-
(append compilation-search-path (list root)
5413-
(mapcar (lambda (f) (expand-file-name f root))
5414-
(projectile-current-project-dirs)))
5415-
compilation-search-path)))
5416-
(apply orig-fun `(,marker ,filename ,directory ,@formats))))
5409+
; If the file already exists, don't bother running the extra logic as the project directories might be massive (i.e. Unreal-sized).
5410+
(if (file-exists-p filename)
5411+
(apply orig-fun `(,marker ,filename ,directory ,@formats))
5412+
5413+
(let* ((root (projectile-project-root))
5414+
(compilation-search-path
5415+
(if (projectile-project-p)
5416+
(append compilation-search-path (list root)
5417+
(mapcar (lambda (f) (expand-file-name f root))
5418+
(projectile-current-project-dirs)))
5419+
compilation-search-path)))
5420+
(apply orig-fun `(,marker ,filename ,directory ,@formats)))))
54175421

54185422
(defun projectile-open-projects ()
54195423
"Return a list of all open projects.

0 commit comments

Comments
 (0)