From: Ricardo Wurmus <rekado@elephly.net>
To: 46100@debbugs.gnu.org, 46102@debbugs.gnu.org
Subject: [bug#46102] [PATCH 2/4] inferior: Memoize inferior-package->manifest-entry.
Date: Mon, 25 Jan 2021 14:37:36 +0100 [thread overview]
Message-ID: <20210125133738.15609-2-rekado@elephly.net> (raw)
In-Reply-To: <20210125133738.15609-1-rekado@elephly.net>
* guix/inferior.scm (inferior-package->manifest-entry): Memoize.
---
guix/inferior.scm | 55 ++++++++++++++++++++++++++---------------------
1 file changed, 30 insertions(+), 25 deletions(-)
diff --git a/guix/inferior.scm b/guix/inferior.scm
index da6983d9a6..7bfce5d810 100644
--- a/guix/inferior.scm
+++ b/guix/inferior.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Ricardo Wurmus <rekado@elephly.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -639,31 +640,35 @@ failing when GUIX is too old and lacks the 'guix repl' command."
;;; Manifest entries.
;;;
-(define* (inferior-package->manifest-entry package
- #:optional (output "out")
- #:key (parent (delay #f))
- (properties '()))
- "Return a manifest entry for the OUTPUT of package PACKAGE."
- ;; For each dependency, keep a promise pointing to its "parent" entry.
- (letrec* ((deps (map (match-lambda
- ((label package)
- (inferior-package->manifest-entry package
- #:parent (delay entry)))
- ((label package output)
- (inferior-package->manifest-entry package output
- #:parent (delay entry))))
- (inferior-package-propagated-inputs package)))
- (entry (manifest-entry
- (name (inferior-package-name package))
- (version (inferior-package-version package))
- (output output)
- (item package)
- (dependencies (delete-duplicates deps))
- (search-paths
- (inferior-package-transitive-native-search-paths package))
- (parent parent)
- (properties properties))))
- entry))
+(define inferior-package->manifest-entry
+ (let ((results vlist-null))
+ (lambda* (package #:optional (output "out")
+ #:key (parent (delay #f))
+ (properties '()))
+ "Return a manifest entry for the OUTPUT of package PACKAGE."
+ (or (and=> (vhash-assoc package results) cdr)
+ ;; For each dependency, keep a promise pointing to its "parent" entry.
+ (letrec* ((deps (map (match-lambda
+ ((label package)
+ (inferior-package->manifest-entry package
+ #:parent (delay entry)))
+ ((label package output)
+ (inferior-package->manifest-entry package output
+ #:parent (delay entry))))
+ (inferior-package-propagated-inputs package)))
+ (entry (manifest-entry
+ (name (inferior-package-name package))
+ (version (inferior-package-version package))
+ (output output)
+ (item package)
+ (dependencies (delete-duplicates deps))
+ (search-paths
+ (inferior-package-transitive-native-search-paths package))
+ (parent parent)
+ (properties properties))))
+ (begin
+ (set! results (vhash-cons package entry results))
+ entry))))))
\f
;;;
--
2.29.2
next prev parent reply other threads:[~2021-01-25 13:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-25 13:37 [bug#46101] [PATCH 1/4] guix: Fix typo Ricardo Wurmus
2021-01-25 13:37 ` Ricardo Wurmus [this message]
2021-01-26 10:41 ` [bug#46100] [PATCH 0/4] Memoize inferior package access Ludovic Courtès
2021-01-26 11:30 ` Ludovic Courtès
2021-01-26 12:38 ` Ricardo Wurmus
2021-01-27 23:18 ` Ludovic Courtès
2021-01-28 11:53 ` Ricardo Wurmus
2021-01-28 13:16 ` bug#46100: " Ludovic Courtès
2021-01-25 13:37 ` [bug#46101] [PATCH 3/4] inferior: Memoize inferior package search path access Ricardo Wurmus
2021-01-25 13:37 ` [bug#46100] [PATCH 4/4] inferior: Memoize package input field access Ricardo Wurmus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210125133738.15609-2-rekado@elephly.net \
--to=rekado@elephly.net \
--cc=46100@debbugs.gnu.org \
--cc=46102@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).