From 3be2a5da11018f03c9c0806038058ee8011faf45 Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Mon, 8 Nov 2021 15:13:34 -0800 Subject: [PATCH 1/2] Improve performance when checking case-sensitivity of Tramp file names * lisp/net/tramp.el (tramp-handle-file-name-case-insensitive-p): Use 'tramp-connectable-p' to test for connection. * lisp/net/tramp-sh.el (tramp-sh-handle-expand-file-name): Dissect file name before testing for connectability to reduce duplicated work. --- lisp/net/tramp-sh.el | 8 ++++---- lisp/net/tramp.el | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 6292190940..56dcd61e5c 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -2705,11 +2705,11 @@ tramp-sh-handle-expand-file-name ;; Unless NAME is absolute, concat DIR and NAME. (unless (file-name-absolute-p name) (setq name (tramp-compat-file-name-concat dir name))) + ;; Dissect NAME. + (with-parsed-tramp-file-name name nil ;; If connection is not established yet, run the real handler. - (if (not (tramp-connectable-p name)) - (tramp-run-real-handler #'expand-file-name (list name nil)) - ;; Dissect NAME. - (with-parsed-tramp-file-name name nil + (if (not (tramp-connectable-p v)) + (tramp-run-real-handler #'expand-file-name (list name nil)) (unless (tramp-run-real-handler #'file-name-absolute-p (list localname)) (setq localname (concat "~/" localname))) ;; Tilde expansion if necessary. This needs a shell which diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index b152584c1f..a8972ce69e 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3484,7 +3484,7 @@ tramp-handle-file-name-case-insensitive-p (tramp-get-method-parameter v 'tramp-case-insensitive) ;; There isn't. So we must check, in case there's a connection already. - (and (file-remote-p filename nil 'connected) + (and (let ((non-essential t)) (tramp-connectable-p v)) (with-tramp-connection-property v "case-insensitive" (ignore-errors (with-tramp-progress-reporter v 5 "Checking case-insensitive" -- 2.25.1