self: Optimize 'file-append*' for 'local-file?'.
authorLudovic Courtès <ludo@gnu.org>
Mon, 25 May 2020 15:33:04 +0000 (17:33 +0200)
committerLudovic Courtès <ludo@gnu.org>
Mon, 25 May 2020 21:00:30 +0000 (23:00 +0200)
* guix/self.scm (file-append*): Add 'local-file?' case.
* guix/gexp.scm (local-file-select?): Export.

guix/gexp.scm
guix/self.scm

index 9e193c7..510a1d5 100644 (file)
@@ -51,6 +51,7 @@
             local-file-absolute-file-name
             local-file-name
             local-file-recursive?
+            local-file-select?
 
             plain-file
             plain-file?
index a956804..60fe6e6 100644 (file)
@@ -213,7 +213,15 @@ record with the new file name."
      ;; itself.
      (local-file (string-append item "/" file)
                  #:recursive? recursive?))
-    ;; TODO: Add 'local-file?' case.
+    ((? local-file? base)
+     ;; Likewise, but with a <local-file>.
+     (if (local-file-recursive? base)
+         (local-file (string-append (local-file-absolute-file-name base)
+                                    "/" file)
+                     (basename file)
+                     #:recursive? recursive?
+                     #:select? (local-file-select? base))
+         (file-append base file)))
     (_
      ;; In this case, anything that refers to the result also depends on ITEM,
      ;; which isn't great.