Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid expensive file-truename call when possible #3430

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- Improve the presentation of `xref` data.
- [#3419](https://github.com/clojure-emacs/cider/issues/3419): Also match friendly sessions based on the buffer's ns form.
- `cider-test`: only show diffs for collections.
- Avoid expensive `file-truename` call when possible.
- [#3375](https://github.com/clojure-emacs/cider/pull/3375): `cider-test`: don't render a newline between expected and actual, most times.
- Improve `nrepl-dict` error reporting.
- Bump the injected `piggieback` to [0.5.3](https://github.com/nrepl/piggieback/blob/0.5.3/CHANGES.md#053-2021-10-26).
Expand Down
11 changes: 10 additions & 1 deletion cider-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,16 @@ The checking is done as follows:
(setcdr session (seq-filter #'buffer-live-p (cdr session)))
(when-let* ((repl (cadr session))
(proc (get-buffer-process repl))
(file (file-truename (or (buffer-file-name) default-directory))))
(file (or
;; favor a built-in buffer-local variable if possible, for performance:
(and buffer-file-truename
(if (file-remote-p buffer-file-truename)
buffer-file-truename
;; buffer-file-truename has symlinks resolved, but can be abbreviated,
;; except in remote files. Expand it:
(expand-file-name buffer-file-truename)))
;; else, call file-truename, which is expensive:
(file-truename (or (buffer-file-name) default-directory)))))
;; With avfs paths look like /path/to/.avfs/path/to/some.jar#uzip/path/to/file.clj
(when (string-match-p "#uzip" file)
(let ((avfs-path (directory-file-name (expand-file-name (or (getenv "AVFSBASE") "~/.avfs/")))))
Expand Down