diff --git a/CHANGELOG.md b/CHANGELOG.md index cba6dd11e..ef7689798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). diff --git a/cider-repl.el b/cider-repl.el index a6f1ef297..80f4e2378 100644 --- a/cider-repl.el +++ b/cider-repl.el @@ -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/")))))