diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-10-13 22:33:31 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-10-13 23:34:09 +0200 |
commit | 1391dcb054f42e9ca58496db3269bee6e05f9653 (patch) | |
tree | dded0d94587963875dc085a41d93a01229bec54b | |
parent | 3de9a5936c09038d5eeb1fab6966f34f8ea30574 (diff) | |
download | patches-1391dcb054f42e9ca58496db3269bee6e05f9653.tar patches-1391dcb054f42e9ca58496db3269bee6e05f9653.tar.gz |
derivations: Memoize 'derivation-path->base16-hash'.
This reduces run time of (package-derivation s emacs) by ~10%.
* guix/derivations.scm (derivation-path->base16-hash): New procedure.
(derivation-hash): Use it.
-rw-r--r-- | guix/derivations.scm | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/guix/derivations.scm b/guix/derivations.scm index 7e974bf541..210afd2ed1 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm @@ -489,6 +489,16 @@ in SIZE bytes." (logxor o (bytevector-u8-ref bv i))) (loop (+ 1 i)))))) +(define derivation-path->base16-hash + (memoize + (lambda (file) + "Return a string containing the base16 representation of the hash of the +derivation at FILE." + (call-with-input-file file + (compose bytevector->base16-string + derivation-hash + read-derivation))))) + (define derivation-hash ; `hashDerivationModulo' in derivations.cc (memoize (lambda (drv) @@ -512,10 +522,7 @@ in SIZE bytes." ;; derivation. (let* ((inputs (map (match-lambda (($ <derivation-input> path sub-drvs) - (let ((hash (call-with-input-file path - (compose bytevector->base16-string - derivation-hash - read-derivation)))) + (let ((hash (derivation-path->base16-hash path))) (make-derivation-input hash sub-drvs)))) inputs)) (drv (make-derivation outputs inputs sources |