guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/06: packages: Turn 'cache!' into a single-value-return cache.


From: guix-commits
Subject: 03/06: packages: Turn 'cache!' into a single-value-return cache.
Date: Wed, 19 Dec 2018 18:09:42 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 0b1be8fd57233c11e3b8ad71bd20af9349539cbd
Author: Ludovic Courtès <address@hidden>
Date:   Sun Jun 25 16:31:33 2017 +0200

    packages: Turn 'cache!' into a single-value-return cache.
    
    * guix/packages.scm (cache!): Assume THUNK returns a single value.
    (cached): Likewise.
---
 guix/packages.scm | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/guix/packages.scm b/guix/packages.scm
index eab0b34..e4c2ac3 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -870,14 +870,14 @@ OVERRIDES."
 SYSTEM."
   ;; FIXME: This memoization should be associated with the open store, because
   ;; otherwise it breaks when switching to a different store.
-  (let ((vals (call-with-values thunk list)))
+  (let ((result (thunk)))
     ;; 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! cache package
-                `((,system ,@vals)
+                `((,system . ,result)
                   ,@(or (hashq-ref cache package) '())))
-    (apply values vals)))
+    result))
 
 (define-syntax cached
   (syntax-rules (=>)
@@ -889,10 +889,8 @@ Return the cached result when available."
        (match (hashq-ref cache package)
          ((alist (... ...))
           (match (assoc-ref alist key)
-            ((vals (... ...))
-             (apply values vals))
-            (#f
-             (cache! cache package key thunk))))
+            (#f (cache! cache package key thunk))
+            (value value)))
          (#f
           (cache! cache package key thunk)))))
     ((_ package system body ...)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]