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'.
This commit is contained in:
Ludovic Courtès 2014-10-13 23:00:06 +02:00
parent 1391dcb054
commit 8601d0ddcf
1 changed files with 6 additions and 1 deletions

View File

@ -893,6 +893,11 @@ system, imported, and appears under FINAL-PATH in the resulting store path."
#:guile-for-build guile #:guile-for-build guile
#:local-build? #t))) #: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 (define* (imported-modules store modules
#:key (name "module-import") #:key (name "module-import")
(system (%current-system)) (system (%current-system))
@ -907,7 +912,7 @@ search path."
(let ((f (string-append (let ((f (string-append
(string-join (map symbol->string m) "/") (string-join (map symbol->string m) "/")
".scm"))) ".scm")))
(cons f (search-path module-path f)))) (cons f (search-path* module-path f))))
modules))) modules)))
(imported-files store files #:name name #:system system (imported-files store files #:name name #:system system
#:guile guile))) #:guile guile)))