aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2015-11-11 11:47:26 +0100
committerMichael Albinus2015-11-11 11:47:26 +0100
commitef75c3b56b8ff034eb47e0c69328227127cc93fa (patch)
tree1d10f8bfc4efe05495bf04a6d265d91f9e56706f
parent25775a12c5168b0494dff15639ac25d8e1017530 (diff)
downloademacs-ef75c3b56b8ff034eb47e0c69328227127cc93fa.tar.gz
emacs-ef75c3b56b8ff034eb47e0c69328227127cc93fa.zip
Optimize `file-equal-p' and `file-in-directory-p' in Tramp
* lisp/net/tramp.el (tramp-handle-file-equal-p) (tramp-handle-file-in-directory-p): New defuns. Suggested by Harvey Chapman <hchapman@3gfp.com> * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): Use them.
-rw-r--r--lisp/net/tramp-adb.el4
-rw-r--r--lisp/net/tramp-gvfs.el4
-rw-r--r--lisp/net/tramp-sh.el4
-rw-r--r--lisp/net/tramp-smb.el4
-rw-r--r--lisp/net/tramp.el20
5 files changed, 28 insertions, 8 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 88dea6a7e35..178b3a0fd11 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -117,11 +117,11 @@ It is used for TCP/IP devices."
117 (file-acl . ignore) 117 (file-acl . ignore)
118 (file-attributes . tramp-adb-handle-file-attributes) 118 (file-attributes . tramp-adb-handle-file-attributes)
119 (file-directory-p . tramp-adb-handle-file-directory-p) 119 (file-directory-p . tramp-adb-handle-file-directory-p)
120 ;; `file-equal-p' performed by default handler. 120 (file-equal-p . tramp-handle-file-equal-p)
121 ;; FIXME: This is too sloppy. 121 ;; FIXME: This is too sloppy.
122 (file-executable-p . tramp-handle-file-exists-p) 122 (file-executable-p . tramp-handle-file-exists-p)
123 (file-exists-p . tramp-handle-file-exists-p) 123 (file-exists-p . tramp-handle-file-exists-p)
124 ;; `file-in-directory-p' performed by default handler. 124 (file-in-directory-p . tramp-handle-file-in-directory-p)
125 (file-local-copy . tramp-adb-handle-file-local-copy) 125 (file-local-copy . tramp-adb-handle-file-local-copy)
126 (file-modes . tramp-handle-file-modes) 126 (file-modes . tramp-handle-file-modes)
127 (file-name-all-completions . tramp-adb-handle-file-name-all-completions) 127 (file-name-all-completions . tramp-adb-handle-file-name-all-completions)
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 8683241fcd1..c5a60751d5b 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -430,10 +430,10 @@ Every entry is a list (NAME ADDRESS).")
430 (file-acl . ignore) 430 (file-acl . ignore)
431 (file-attributes . tramp-gvfs-handle-file-attributes) 431 (file-attributes . tramp-gvfs-handle-file-attributes)
432 (file-directory-p . tramp-gvfs-handle-file-directory-p) 432 (file-directory-p . tramp-gvfs-handle-file-directory-p)
433 ;; `file-equal-p' performed by default handler. 433 (file-equal-p . tramp-handle-file-equal-p)
434 (file-executable-p . tramp-gvfs-handle-file-executable-p) 434 (file-executable-p . tramp-gvfs-handle-file-executable-p)
435 (file-exists-p . tramp-handle-file-exists-p) 435 (file-exists-p . tramp-handle-file-exists-p)
436 ;; `file-in-directory-p' performed by default handler. 436 (file-in-directory-p . tramp-handle-file-in-directory-p)
437 (file-local-copy . tramp-gvfs-handle-file-local-copy) 437 (file-local-copy . tramp-gvfs-handle-file-local-copy)
438 (file-modes . tramp-handle-file-modes) 438 (file-modes . tramp-handle-file-modes)
439 (file-name-all-completions . tramp-gvfs-handle-file-name-all-completions) 439 (file-name-all-completions . tramp-gvfs-handle-file-name-all-completions)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 1753c73f869..f5ff6a7adec 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -993,10 +993,10 @@ of command line.")
993 (file-acl . tramp-sh-handle-file-acl) 993 (file-acl . tramp-sh-handle-file-acl)
994 (file-attributes . tramp-sh-handle-file-attributes) 994 (file-attributes . tramp-sh-handle-file-attributes)
995 (file-directory-p . tramp-sh-handle-file-directory-p) 995 (file-directory-p . tramp-sh-handle-file-directory-p)
996 ;; `file-equal-p' performed by default handler. 996 (file-equal-p . tramp-handle-file-equal-p)
997 (file-executable-p . tramp-sh-handle-file-executable-p) 997 (file-executable-p . tramp-sh-handle-file-executable-p)
998 (file-exists-p . tramp-sh-handle-file-exists-p) 998 (file-exists-p . tramp-sh-handle-file-exists-p)
999 ;; `file-in-directory-p' performed by default handler. 999 (file-in-directory-p . tramp-handle-file-in-directory-p)
1000 (file-local-copy . tramp-sh-handle-file-local-copy) 1000 (file-local-copy . tramp-sh-handle-file-local-copy)
1001 (file-modes . tramp-handle-file-modes) 1001 (file-modes . tramp-handle-file-modes)
1002 (file-name-all-completions . tramp-sh-handle-file-name-all-completions) 1002 (file-name-all-completions . tramp-sh-handle-file-name-all-completions)
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index c95679584dc..65c77eba0eb 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -232,10 +232,10 @@ See `tramp-actions-before-shell' for more info.")
232 (file-acl . tramp-smb-handle-file-acl) 232 (file-acl . tramp-smb-handle-file-acl)
233 (file-attributes . tramp-smb-handle-file-attributes) 233 (file-attributes . tramp-smb-handle-file-attributes)
234 (file-directory-p . tramp-smb-handle-file-directory-p) 234 (file-directory-p . tramp-smb-handle-file-directory-p)
235 ;; `file-equal-p' performed by default handler. 235 (file-file-equal-p . tramp-handle-file-equal-p)
236 (file-executable-p . tramp-handle-file-exists-p) 236 (file-executable-p . tramp-handle-file-exists-p)
237 (file-exists-p . tramp-handle-file-exists-p) 237 (file-exists-p . tramp-handle-file-exists-p)
238 ;; `file-in-directory-p' performed by default handler. 238 (file-in-directory-p . tramp-handle-file-in-directory-p)
239 (file-local-copy . tramp-smb-handle-file-local-copy) 239 (file-local-copy . tramp-smb-handle-file-local-copy)
240 (file-modes . tramp-handle-file-modes) 240 (file-modes . tramp-handle-file-modes)
241 (file-name-all-completions . tramp-smb-handle-file-name-all-completions) 241 (file-name-all-completions . tramp-smb-handle-file-name-all-completions)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 89aad07ddfe..42a9e3d6710 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -2910,10 +2910,30 @@ User is always nil."
2910 (and (file-directory-p filename) 2910 (and (file-directory-p filename)
2911 (file-readable-p filename))) 2911 (file-readable-p filename)))
2912 2912
2913(defun tramp-handle-file-equal-p (filename1 filename2)
2914 "Like `file-equalp-p' for Tramp files."
2915 ;; Native `file-equalp-p' calls `file-truename', which requires a
2916 ;; remote connection. This can be avoided, if FILENAME1 and
2917 ;; FILENAME2 are not located on the same remote host.
2918 (when (string-equal
2919 (file-remote-p (expand-file-name filename1))
2920 (file-remote-p (expand-file-name filename2)))
2921 (tramp-run-real-handler 'file-equal-p (list filename1 filename2))))
2922
2913(defun tramp-handle-file-exists-p (filename) 2923(defun tramp-handle-file-exists-p (filename)
2914 "Like `file-exists-p' for Tramp files." 2924 "Like `file-exists-p' for Tramp files."
2915 (not (null (file-attributes filename)))) 2925 (not (null (file-attributes filename))))
2916 2926
2927(defun tramp-handle-file-in-directory-p (filename directory)
2928 "Like `file-in-directory-p' for Tramp files."
2929 ;; Native `file-in-directory-p' calls `file-truename', which
2930 ;; requires a remote connection. This can be avoided, if FILENAME
2931 ;; and DIRECTORY are not located on the same remote host.
2932 (when (string-equal
2933 (file-remote-p (expand-file-name filename))
2934 (file-remote-p (expand-file-name directory)))
2935 (tramp-run-real-handler 'file-in-directory-p (list filename directory))))
2936
2917(defun tramp-handle-file-modes (filename) 2937(defun tramp-handle-file-modes (filename)
2918 "Like `file-modes' for Tramp files." 2938 "Like `file-modes' for Tramp files."
2919 (let ((truename (or (file-truename filename) filename))) 2939 (let ((truename (or (file-truename filename) filename)))