[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master ef75c3b: Optimize `file-equal-p' and `file-in-direc
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] master ef75c3b: Optimize `file-equal-p' and `file-in-directory-p' in Tramp |
Date: |
Wed, 11 Nov 2015 10:47:38 +0000 |
branch: master
commit ef75c3b56b8ff034eb47e0c69328227127cc93fa
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
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 <address@hidden>
* 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.
---
lisp/net/tramp-adb.el | 4 ++--
lisp/net/tramp-gvfs.el | 4 ++--
lisp/net/tramp-sh.el | 4 ++--
lisp/net/tramp-smb.el | 4 ++--
lisp/net/tramp.el | 20 ++++++++++++++++++++
5 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 88dea6a..178b3a0 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -117,11 +117,11 @@ It is used for TCP/IP devices."
(file-acl . ignore)
(file-attributes . tramp-adb-handle-file-attributes)
(file-directory-p . tramp-adb-handle-file-directory-p)
- ;; `file-equal-p' performed by default handler.
+ (file-equal-p . tramp-handle-file-equal-p)
;; FIXME: This is too sloppy.
(file-executable-p . tramp-handle-file-exists-p)
(file-exists-p . tramp-handle-file-exists-p)
- ;; `file-in-directory-p' performed by default handler.
+ (file-in-directory-p . tramp-handle-file-in-directory-p)
(file-local-copy . tramp-adb-handle-file-local-copy)
(file-modes . tramp-handle-file-modes)
(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 8683241..c5a6075 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -430,10 +430,10 @@ Every entry is a list (NAME ADDRESS).")
(file-acl . ignore)
(file-attributes . tramp-gvfs-handle-file-attributes)
(file-directory-p . tramp-gvfs-handle-file-directory-p)
- ;; `file-equal-p' performed by default handler.
+ (file-equal-p . tramp-handle-file-equal-p)
(file-executable-p . tramp-gvfs-handle-file-executable-p)
(file-exists-p . tramp-handle-file-exists-p)
- ;; `file-in-directory-p' performed by default handler.
+ (file-in-directory-p . tramp-handle-file-in-directory-p)
(file-local-copy . tramp-gvfs-handle-file-local-copy)
(file-modes . tramp-handle-file-modes)
(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 1753c73..f5ff6a7 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -993,10 +993,10 @@ of command line.")
(file-acl . tramp-sh-handle-file-acl)
(file-attributes . tramp-sh-handle-file-attributes)
(file-directory-p . tramp-sh-handle-file-directory-p)
- ;; `file-equal-p' performed by default handler.
+ (file-equal-p . tramp-handle-file-equal-p)
(file-executable-p . tramp-sh-handle-file-executable-p)
(file-exists-p . tramp-sh-handle-file-exists-p)
- ;; `file-in-directory-p' performed by default handler.
+ (file-in-directory-p . tramp-handle-file-in-directory-p)
(file-local-copy . tramp-sh-handle-file-local-copy)
(file-modes . tramp-handle-file-modes)
(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 c956795..65c77eb 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.")
(file-acl . tramp-smb-handle-file-acl)
(file-attributes . tramp-smb-handle-file-attributes)
(file-directory-p . tramp-smb-handle-file-directory-p)
- ;; `file-equal-p' performed by default handler.
+ (file-file-equal-p . tramp-handle-file-equal-p)
(file-executable-p . tramp-handle-file-exists-p)
(file-exists-p . tramp-handle-file-exists-p)
- ;; `file-in-directory-p' performed by default handler.
+ (file-in-directory-p . tramp-handle-file-in-directory-p)
(file-local-copy . tramp-smb-handle-file-local-copy)
(file-modes . tramp-handle-file-modes)
(file-name-all-completions . tramp-smb-handle-file-name-all-completions)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 89aad07..42a9e3d 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -2910,10 +2910,30 @@ User is always nil."
(and (file-directory-p filename)
(file-readable-p filename)))
+(defun tramp-handle-file-equal-p (filename1 filename2)
+ "Like `file-equalp-p' for Tramp files."
+ ;; Native `file-equalp-p' calls `file-truename', which requires a
+ ;; remote connection. This can be avoided, if FILENAME1 and
+ ;; FILENAME2 are not located on the same remote host.
+ (when (string-equal
+ (file-remote-p (expand-file-name filename1))
+ (file-remote-p (expand-file-name filename2)))
+ (tramp-run-real-handler 'file-equal-p (list filename1 filename2))))
+
(defun tramp-handle-file-exists-p (filename)
"Like `file-exists-p' for Tramp files."
(not (null (file-attributes filename))))
+(defun tramp-handle-file-in-directory-p (filename directory)
+ "Like `file-in-directory-p' for Tramp files."
+ ;; Native `file-in-directory-p' calls `file-truename', which
+ ;; requires a remote connection. This can be avoided, if FILENAME
+ ;; and DIRECTORY are not located on the same remote host.
+ (when (string-equal
+ (file-remote-p (expand-file-name filename))
+ (file-remote-p (expand-file-name directory)))
+ (tramp-run-real-handler 'file-in-directory-p (list filename directory))))
+
(defun tramp-handle-file-modes (filename)
"Like `file-modes' for Tramp files."
(let ((truename (or (file-truename filename) filename)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master ef75c3b: Optimize `file-equal-p' and `file-in-directory-p' in Tramp,
Michael Albinus <=