]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid unnecessary consing in project--files-in-directory
authorDmitry Gutov <dgutov@yandex.ru>
Thu, 7 Feb 2019 11:22:47 +0000 (14:22 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Thu, 7 Feb 2019 11:22:47 +0000 (14:22 +0300)
* lisp/progmodes/project.el (project--remote-file-names): New function.
(project--files-in-directory): Use it.

lisp/progmodes/project.el

index 3906f6cb24b29ef5242c40faa3e02e6962c842ed..fbf761c60c901efd72399702444c815c3d722dd5 100644 (file)
@@ -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."