emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 3d6d8d7: Avoid unnecessary consing in project--file


From: Dmitry Gutov
Subject: [Emacs-diffs] master 3d6d8d7: Avoid unnecessary consing in project--files-in-directory
Date: Thu, 7 Feb 2019 06:23:02 -0500 (EST)

branch: master
commit 3d6d8d795b593df3fa2132e23811ad1e94a58c05
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Avoid unnecessary consing in project--files-in-directory
    
    * lisp/progmodes/project.el (project--remote-file-names): New function.
    (project--files-in-directory): Use it.
---
 lisp/progmodes/project.el | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 3906f6c..fbf761c 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -192,7 +192,6 @@ to find the list of ignores for each directory."
   (require 'find-dired)
   (defvar find-name-arg)
   (let ((default-directory dir)
-        (remote-id (file-remote-p dir))
         (command (format "%s %s %s -type f %s -print0"
                          find-program
                          (file-local-name dir)
@@ -209,8 +208,17 @@ to find the list of ignores for each directory."
                                      " "
                                      (shell-quote-argument ")"))"")
                          )))
-    (mapcar (lambda (file) (concat remote-id file))
-            (split-string (shell-command-to-string command) "\0" t))))
+    (project--remote-file-names
+     (split-string (shell-command-to-string command) "\0" t))))
+
+(defun project--remote-file-names (local-files)
+  "Return LOCAL-FILES as if they were on the system of `default-directory'."
+  (let ((remote-id (file-remote-p default-directory)))
+    (if (not remote-id)
+        local-files
+      (mapcar (lambda (file)
+                (concat remote-id file))
+              local-files))))
 
 (defgroup project-vc nil
   "Project implementation using the VC package."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]