From: Daanturo Date: Thu, 1 Sep 2022 10:08:05 +0000 (+0200) Subject: Make file-parent-directory more efficient X-Git-Tag: emacs-29.0.90~1856^2~807 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f0319cd86f8d147e443bcaa0927937ccf052fbd0;p=emacs.git Make file-parent-directory more efficient * lisp/files.el (file-parent-directory): Use equal instead of file-equal-p to compare the found parent and the child (bug#56355). This is much faster. --- diff --git a/lisp/files.el b/lisp/files.el index 740e09055bb..b084dca8b7d 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -5196,7 +5196,9 @@ to `default-directory', and the result will also be relative." (cond ;; filename is at top-level, therefore no parent ((or (null parent) - (file-equal-p parent expanded-filename)) + ;; `equal' is enough, we don't need to resolve symlinks here + ;; with `file-equal-p', also for performance + (equal parent expanded-filename)) nil) ;; filename is relative, return relative parent ((not (file-name-absolute-p filename))