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.
This commit is contained in:
parent
3de9a5936c
commit
1391dcb054
|
@ -489,6 +489,16 @@ in SIZE bytes."
|
||||||
(logxor o (bytevector-u8-ref bv i)))
|
(logxor o (bytevector-u8-ref bv i)))
|
||||||
(loop (+ 1 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
|
(define derivation-hash ; `hashDerivationModulo' in derivations.cc
|
||||||
(memoize
|
(memoize
|
||||||
(lambda (drv)
|
(lambda (drv)
|
||||||
|
@ -512,10 +522,7 @@ in SIZE bytes."
|
||||||
;; derivation.
|
;; derivation.
|
||||||
(let* ((inputs (map (match-lambda
|
(let* ((inputs (map (match-lambda
|
||||||
(($ <derivation-input> path sub-drvs)
|
(($ <derivation-input> path sub-drvs)
|
||||||
(let ((hash (call-with-input-file path
|
(let ((hash (derivation-path->base16-hash path)))
|
||||||
(compose bytevector->base16-string
|
|
||||||
derivation-hash
|
|
||||||
read-derivation))))
|
|
||||||
(make-derivation-input hash sub-drvs))))
|
(make-derivation-input hash sub-drvs))))
|
||||||
inputs))
|
inputs))
|
||||||
(drv (make-derivation outputs inputs sources
|
(drv (make-derivation outputs inputs sources
|
||||||
|
|
Loading…
Reference in New Issue