summaryrefslogtreecommitdiff
path: root/guix/packages.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-10-15 09:22:23 +0200
committerLudovic Courtès <ludo@gnu.org>2014-10-17 23:23:20 +0200
commit8dcec9142667d0b29cf71ca55cf48c0c4f5d4400 (patch)
treeb87e340cf65d67a2d010fd5b30204103b5a067dd /guix/packages.scm
parent3d7d17b31866a99cd86566e9939a3298af8623c7 (diff)
packages: Improve the package-to-derivation cache.
* guix/packages.scm (cache): Preserve the former values associated with PACKAGE. (cached): Bind SYSTEM in 'let', to prevent double evaluation.
Diffstat (limited to 'guix/packages.scm')
-rw-r--r--guix/packages.scm14
1 files changed, 9 insertions, 5 deletions
diff --git a/guix/packages.scm b/guix/packages.scm
index b397a24678..070eb4e9d5 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -573,22 +573,26 @@ SYSTEM."
;; Use `hashq-set!' instead of `hash-set!' because `hash' returns the
;; same value for all structs (as of Guile 2.0.6), and because pointer
;; equality is sufficient in practice.
- (hashq-set! %derivation-cache package `((,system ,@vals)))
+ (hashq-set! %derivation-cache package
+ `((,system ,@vals)
+ ,@(or (hashq-ref %derivation-cache package)
+ '())))
(apply values vals)))
(define-syntax-rule (cached package system body ...)
"Memoize the result of BODY for the arguments PACKAGE and SYSTEM.
Return the cached result when available."
- (let ((thunk (lambda () body ...)))
+ (let ((thunk (lambda () body ...))
+ (key system))
(match (hashq-ref %derivation-cache package)
((alist (... ...))
- (match (assoc-ref alist system)
+ (match (assoc-ref alist key)
((vals (... ...))
(apply values vals))
(#f
- (cache package system thunk))))
+ (cache package key thunk))))
(#f
- (cache package system thunk)))))
+ (cache package key thunk)))))
(define* (expand-input store package input system #:optional cross-system)
"Expand INPUT, an input tuple, such that it contains only references to