From 8601d0ddcf5f0c1123d7679924560bc1b6b0e846 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 13 Oct 2014 23:00:06 +0200 Subject: derivations: Micro-optimize 'imported-modules'. This reduces run time of (package-derivation s emacs) by ~5%. * guix/derivations.scm (search-path*): New procedure. (imported-modules): Use it instead of 'search-path'. --- guix/derivations.scm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/guix/derivations.scm b/guix/derivations.scm index 210afd2ed1..c0b69e71d6 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm @@ -893,6 +893,11 @@ (define* (imported-files store files #:guile-for-build guile #:local-build? #t))) +(define search-path* + ;; A memoizing version of 'search-path' so 'imported-modules' does not end + ;; up looking for the same files over and over again. + (memoize search-path)) + (define* (imported-modules store modules #:key (name "module-import") (system (%current-system)) @@ -907,7 +912,7 @@ (define* (imported-modules store modules (let ((f (string-append (string-join (map symbol->string m) "/") ".scm"))) - (cons f (search-path module-path f)))) + (cons f (search-path* module-path f)))) modules))) (imported-files store files #:name name #:system system #:guile guile))) -- cgit v1.2.3