derivations: 'derivation' preserves pointer equality.

* guix/derivations.scm (derivation): Check if FILE is already in
%DERIVATION-CACHE and return it if it is.
This commit is contained in:
Ludovic Courtès 2019-06-23 11:40:16 +02:00
parent 5cf4b26d52
commit fd951cd543
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 6 additions and 2 deletions

View File

@ -873,8 +873,12 @@ derivation. It is kept as-is, uninterpreted, in the derivation."
(append (map derivation-input-path inputs)
sources)))
(drv* (set-field drv (derivation-file-name) file)))
;; Preserve pointer equality. This improves the performance of
;; 'eq?'-memoization on derivations.
(or (hash-ref %derivation-cache file)
(begin
(hash-set! %derivation-cache file drv*)
drv*)))
drv*)))))
(define (invalidate-derivation-caches!)
"Invalidate internal derivation caches. This is mostly useful for