From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id iGeYDsfJDmD6bwAA0tVLHw (envelope-from ) for ; Mon, 25 Jan 2021 13:38:15 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id AMNfCsfJDmBJJwAAbx9fmQ (envelope-from ) for ; Mon, 25 Jan 2021 13:38:15 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E31739403A4 for ; Mon, 25 Jan 2021 13:38:14 +0000 (UTC) Received: from localhost ([::1]:46632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l424L-0000j1-Qq for larch@yhetil.org; Mon, 25 Jan 2021 08:38:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l424C-0000c1-AB for guix-patches@gnu.org; Mon, 25 Jan 2021 08:38:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:54928) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l424C-0004ZF-3M for guix-patches@gnu.org; Mon, 25 Jan 2021 08:38:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l424B-0001vQ-Vq for guix-patches@gnu.org; Mon, 25 Jan 2021 08:38:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#46102] [PATCH 2/4] inferior: Memoize inferior-package->manifest-entry. Resent-From: Ricardo Wurmus Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 25 Jan 2021 13:38:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46102 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 46100@debbugs.gnu.org, 46102@debbugs.gnu.org X-Debbugs-Original-To: 46100@debbugs.gnu.org, guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16115818827371 (code B ref -1); Mon, 25 Jan 2021 13:38:03 +0000 Received: (at submit) by debbugs.gnu.org; 25 Jan 2021 13:38:02 +0000 Received: from localhost ([127.0.0.1]:38237 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4249-0001uk-NA for submit@debbugs.gnu.org; Mon, 25 Jan 2021 08:38:01 -0500 Received: from lists.gnu.org ([209.51.188.17]:40442) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4246-0001uV-GK for submit@debbugs.gnu.org; Mon, 25 Jan 2021 08:37:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4245-0000T5-4a for guix-patches@gnu.org; Mon, 25 Jan 2021 08:37:58 -0500 Received: from sender4-of-o51.zoho.com ([136.143.188.51]:21104) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4243-0004Tu-7o for guix-patches@gnu.org; Mon, 25 Jan 2021 08:37:56 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1611581871; cv=none; d=zohomail.com; s=zohoarc; b=CWnD/gwIqd53rHHGNxn8aVy63UCpjh8J7QKMNVtyij8FrcJVO0vSDqTf6QwWLf8m+VHz1a6yAquMGm5MzwucOyJGUku1TKvn+uq+a0j2Lgb3ozeInjYcL8rEqmjBa07Sv32vPNgNFc7zHx++5Ati/blIvHBnyqyX+e9ulB3kixc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611581871; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=cAPpwspxUMRYLMxOYgtP5Nr+GXLx0YRveoeqjP/TTB4=; b=Gig9Lplb7GtcF2qaZUAYcvOHAKf0Hi45s2oZel2jkjAYKABXJW6CpG3AspmFc1L1nwqw19/0I6tVug8xEETtJmj6hD81GjXfrphd0V6qFQjjHVaw3PjipmBSEONdiZ6zH615YpiApZk/dYl60cHlVZ1/dFooSP6zYJQFJdtxjyY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1611581871; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=cAPpwspxUMRYLMxOYgtP5Nr+GXLx0YRveoeqjP/TTB4=; b=azYrMg50V74i6Mq1LfWtNsY3XnULIpJHr1z7Ow5Veug1RYS58s1+iPpYcRi2V4LA mOSaLssudN9ziZ/Z9xpaRI9jhbEw5lMeRGIxxP7/MyAdd+tqH734jTg//TWkUAER6Db zLYEfZK6STxuv6N8bUHFbECM6G2cvqmO7sTvPsyQ= Received: from localhost (p54ad4ec7.dip0.t-ipconnect.de [84.173.78.199]) by mx.zohomail.com with SMTPS id 1611581868760918.1867490546068; Mon, 25 Jan 2021 05:37:48 -0800 (PST) From: Ricardo Wurmus Message-ID: <20210125133738.15609-2-rekado@elephly.net> Date: Mon, 25 Jan 2021 14:37:36 +0100 X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210125133738.15609-1-rekado@elephly.net> References: <20210125133738.15609-1-rekado@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Received-SPF: pass client-ip=136.143.188.51; envelope-from=rekado@elephly.net; helo=sender4-of-o51.zoho.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 1.65 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=elephly.net header.s=zoho header.b=azYrMg50; arc=reject ("signature check failed: fail, {[1] = sig:zohomail.com:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: E31739403A4 X-Spam-Score: 1.65 X-Migadu-Scanner: scn0.migadu.com X-TUID: PcNdDvjrKZ+Y * 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 =C2=A9 2018, 2019, 2020 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2021 Ricardo Wurmus ;;; ;;; 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. ;;; =20 -(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 (del= ay entry))) - ((label package output) - (inferior-package->manifest-entry package outpu= t - #:parent (del= ay 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 pac= kage)) - (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=3D> (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 packa= ge + #:par= ent (delay entry))) + ((label package output) + (inferior-package->manifest-entry packa= ge output + #:par= ent (delay entry)))) + (inferior-package-propagated-inputs packag= e))) + (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-p= aths package)) + (parent parent) + (properties properties)))) + (begin + (set! results (vhash-cons package entry results)) + entry)))))) =20 =0C ;;; --=20 2.29.2