summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-06-23 11:40:16 +0200
committerLudovic Courtès <ludo@gnu.org>2019-06-27 11:14:41 +0200
commitfd951cd543d9f4d3ecfa4570e51797f84e79068b (patch)
tree1786d70a803eba0122ebafd33c3ad77a91283e92
parent5cf4b26d52bcea382d98fb4becce89be9ee37b55 (diff)
downloadguix-fd951cd543d9f4d3ecfa4570e51797f84e79068b.tar.gz
derivations: 'derivation' preserves pointer equality.
* guix/derivations.scm (derivation): Check if FILE is already in
%DERIVATION-CACHE and return it if it is.
-rw-r--r--guix/derivations.scm8
1 files changed, 6 insertions, 2 deletions
diff --git a/guix/derivations.scm b/guix/derivations.scm
index 5c568f223b..403e86749b 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -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)))
-      (hash-set! %derivation-cache file drv*)
-      drv*)))
+      ;; 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*)))))
 
 (define (invalidate-derivation-caches!)
   "Invalidate internal derivation caches.  This is mostly useful for