diff mbox series

[bug#46101,3/4] inferior: Memoize inferior package search path access.

Message ID 20210125133738.15609-3-rekado@elephly.net
State Accepted
Headers show
Series Memoize inferior package access. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Ricardo Wurmus Jan. 25, 2021, 1:37 p.m. UTC
* guix/inferior.scm (%inferior-package-search-paths): Return memoized
procedure accepting a package.
(inferior-package-native-search-paths, inferior-package-search-paths,
inferior-package-transitive-native-search-paths): Adapt.
---
 guix/inferior.scm | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/guix/inferior.scm b/guix/inferior.scm
index 7bfce5d810..0c85a9ea08 100644
--- a/guix/inferior.scm
+++ b/guix/inferior.scm
@@ -45,6 +45,7 @@ 
   #:use-module (guix store)
   #:use-module (guix derivations)
   #:use-module (guix base32)
+  #:use-module ((guix memoization) #:select (mlambdaq))
   #:use-module (gcrypt hash)
   #:autoload   (guix cache) (maybe-remove-expired-cache-entries
                              file-expiration-time)
@@ -430,27 +431,28 @@  inferior package."
 (define inferior-package-transitive-propagated-inputs
   (cut inferior-package-input-field <> 'package-transitive-propagated-inputs))
 
-(define (%inferior-package-search-paths package field)
+(define (%inferior-package-search-paths field)
   "Return the list of search path specifications of PACKAGE, an inferior
 package."
-  (define paths
-    (inferior-package-field package
-                            `(compose (lambda (paths)
-                                        (map (@ (guix search-paths)
-                                                search-path-specification->sexp)
-                                             paths))
-                                      ,field)))
+  (mlambdaq (package)
+    (define paths
+      (inferior-package-field package
+                              `(compose (lambda (paths)
+                                          (map (@ (guix search-paths)
+                                                  search-path-specification->sexp)
+                                               paths))
+                                        ,field)))
 
-  (map sexp->search-path-specification paths))
+    (map sexp->search-path-specification paths)))
 
 (define inferior-package-native-search-paths
-  (cut %inferior-package-search-paths <> 'package-native-search-paths))
+  (%inferior-package-search-paths 'package-native-search-paths))
 
 (define inferior-package-search-paths
-  (cut %inferior-package-search-paths <> 'package-search-paths))
+  (%inferior-package-search-paths 'package-search-paths))
 
 (define inferior-package-transitive-native-search-paths
-  (cut %inferior-package-search-paths <> 'package-transitive-native-search-paths))
+  (%inferior-package-search-paths 'package-transitive-native-search-paths))
 
 (define (inferior-package-provenance package)
   "Return a \"provenance sexp\" for PACKAGE, an inferior package.  The result