Skip to content

Commit

Permalink
Optimize compilation-find-file-projectile-find-compilation-buffer (#1874
Browse files Browse the repository at this point in the history
)

If the target file already exists, navigate to it directly instead of running the expensive extra logic.
  • Loading branch information
sonictk authored Jan 22, 2024
1 parent 874ccb3 commit 55e9026
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### New features

* [#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.
* [#1870](https://github.com/bbatsov/projectile/pull/1870): Add package command for CMake projects.
* [#1875](https://github.com/bbatsov/projectile/pull/1875): Add support for Sapling VCS.
* [#1876](https://github.com/bbatsov/projectile/pull/1876): Add support for Jujutsu VCS.
Expand Down
20 changes: 12 additions & 8 deletions projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -5406,14 +5406,18 @@ We enhance its functionality by appending the current project's directories
to its search path. This way when filenames in compilation buffers can't be
found by compilation's normal logic they are searched for in project
directories."
(let* ((root (projectile-project-root))
(compilation-search-path
(if (projectile-project-p)
(append compilation-search-path (list root)
(mapcar (lambda (f) (expand-file-name f root))
(projectile-current-project-dirs)))
compilation-search-path)))
(apply orig-fun `(,marker ,filename ,directory ,@formats))))
; If the file already exists, don't bother running the extra logic as the project directories might be massive (i.e. Unreal-sized).
(if (file-exists-p filename)
(apply orig-fun `(,marker ,filename ,directory ,@formats))

(let* ((root (projectile-project-root))
(compilation-search-path
(if (projectile-project-p)
(append compilation-search-path (list root)
(mapcar (lambda (f) (expand-file-name f root))
(projectile-current-project-dirs)))
compilation-search-path)))
(apply orig-fun `(,marker ,filename ,directory ,@formats)))))

(defun projectile-open-projects ()
"Return a list of all open projects.
Expand Down

0 comments on commit 55e9026

Please sign in to comment.