guix-commits
[Top][All Lists]
Advanced

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

02/02: gexp: 'gexp->script' does not emit load-path expression when unne


From: guix-commits
Subject: 02/02: gexp: 'gexp->script' does not emit load-path expression when unnecessary.
Date: Mon, 7 Jan 2019 17:51:04 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit efff32452a050e2cd715c38717dd03cad5511bc0
Author: Ludovic Courtès <address@hidden>
Date:   Mon Jan 7 23:45:15 2019 +0100

    gexp: 'gexp->script' does not emit load-path expression when unnecessary.
    
    This removes two elements from %LOAD-PATH and %LOAD-COMPILED-PATH of the
    'guix' command and thus further reduces the number of 'stat' calls it
    makes.
    
    * guix/gexp.scm (load-path-expression): Return #f when MODULES and
    EXTENSIONS are both empty.
    (gexp->script): Don't emit anything when SET-LOAD-PATH is #f.
---
 guix/gexp.scm | 57 ++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 32 insertions(+), 25 deletions(-)

diff --git a/guix/gexp.scm b/guix/gexp.scm
index febd72a..f7c0642 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1315,30 +1315,33 @@ they can refer to each other."
                                #:key (extensions '()))
   "Return as a monadic value a gexp that sets '%load-path' and
 '%load-compiled-path' to point to MODULES, a list of module names.  MODULES
-are searched for in PATH."
-  (mlet %store-monad ((modules  (imported-modules modules
-                                                  #:module-path path))
-                      (compiled (compiled-modules modules
-                                                  #:extensions extensions
-                                                  #:module-path path)))
-    (return (gexp (eval-when (expand load eval)
-                    (set! %load-path
-                      (cons (ungexp modules)
-                            (append (map (lambda (extension)
-                                           (string-append extension
-                                                          "/share/guile/site/"
-                                                          (effective-version)))
-                                         '((ungexp-native-splicing 
extensions)))
-                                    %load-path)))
-                    (set! %load-compiled-path
-                      (cons (ungexp compiled)
-                            (append (map (lambda (extension)
-                                           (string-append extension
-                                                          "/lib/guile/"
-                                                          (effective-version)
-                                                          "/site-ccache"))
-                                         '((ungexp-native-splicing 
extensions)))
-                                    %load-compiled-path))))))))
+are searched for in PATH.  Return #f when MODULES and EXTENSIONS are empty."
+  (if (and (null? modules) (null? extensions))
+      (with-monad %store-monad
+        (return #f))
+      (mlet %store-monad ((modules  (imported-modules modules
+                                                      #:module-path path))
+                          (compiled (compiled-modules modules
+                                                      #:extensions extensions
+                                                      #:module-path path)))
+        (return (gexp (eval-when (expand load eval)
+                        (set! %load-path
+                          (cons (ungexp modules)
+                                (append (map (lambda (extension)
+                                               (string-append extension
+                                                              
"/share/guile/site/"
+                                                              
(effective-version)))
+                                             '((ungexp-native-splicing 
extensions)))
+                                        %load-path)))
+                        (set! %load-compiled-path
+                          (cons (ungexp compiled)
+                                (append (map (lambda (extension)
+                                               (string-append extension
+                                                              "/lib/guile/"
+                                                              
(effective-version)
+                                                              "/site-ccache"))
+                                             '((ungexp-native-splicing 
extensions)))
+                                        %load-compiled-path)))))))))
 
 (define* (gexp->script name exp
                        #:key (guile (default-guile))
@@ -1362,7 +1365,11 @@ imported modules in its search path.  Look up EXP's 
modules in MODULE-PATH."
                                    "#!~a/bin/guile --no-auto-compile~%!#~%"
                                    (ungexp guile))
 
-                           (write '(ungexp set-load-path) port)
+                           (ungexp-splicing
+                            (if set-load-path
+                                (gexp ((write '(ungexp set-load-path) port)))
+                                (gexp ())))
+
                            (write '(ungexp exp) port)
                            (chmod port #o555))))
                       #:module-path module-path)))



reply via email to

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