From patchwork Mon Apr 15 15:37:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 63057 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2D76B27BBEA; Mon, 15 Apr 2024 16:39:28 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4657227BBE9 for ; Mon, 15 Apr 2024 16:39:26 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rwOQ8-0006KY-GX; Mon, 15 Apr 2024 11:39:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rwOQ6-0006Jh-2U for guix-patches@gnu.org; Mon, 15 Apr 2024 11:38:58 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rwOQ5-0001en-Ps; Mon, 15 Apr 2024 11:38:57 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rwOQF-00081Q-9K; Mon, 15 Apr 2024 11:39:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70398] [PATCH 5/5] packages: Reduce code bloat due to list allocation in input fields. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Mon, 15 Apr 2024 15:39:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70398 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70398@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 70398-submit@debbugs.gnu.org id=B70398.171319550830489 (code B ref 70398); Mon, 15 Apr 2024 15:39:07 +0000 Received: (at 70398) by debbugs.gnu.org; 15 Apr 2024 15:38:28 +0000 Received: from localhost ([127.0.0.1]:37908 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwOPZ-0007vF-8Z for submit@debbugs.gnu.org; Mon, 15 Apr 2024 11:38:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41200) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwOPH-0007qJ-GZ for 70398@debbugs.gnu.org; Mon, 15 Apr 2024 11:38:11 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rwOP0-0001Uv-F0; Mon, 15 Apr 2024 11:37:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=5vXsn8BSLiVvAWZCYbh1dNBBvzLJn4lDK2zl8EwU1cw=; b=Y0I7T/nN6wfQPUlEGQ0C +40E6lYiOFeR7ItfcJkyd0c6q7xnvj70+3j1J4geC5Kpp4D8xFVqFstFjamN7nvhRI5ADVVIGUccV XKJhrTtdhds1Sl5uCZqt+xC4UDE8C7TAKn24r1/ltWU2vldiv1WisnU8QuqFFnpscz4EJ7WB8iJ5e eZkzAyKeUEIPq3BOLopT99TOiPS6nq2czeif8ajMsmfE9KK6oEIKHMr+cipvbN7pm7FwKAuOHqUTj Li2cx+tVduWn8Iu3KlU1kq6BihadjnEKE8FMRvtC3hZToKlWiRMTb07JPdQnk8YDIfI8tnt2xy2EE 3LLKdRQnXXEv6w==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 15 Apr 2024 17:37:07 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/packages.scm (add-input-labels): New procedure. (sanitize-inputs): Add case for (list …). Change-Id: Ice8241508ded51efd38867b97ca19c262b8c4363 --- guix/packages.scm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/guix/packages.scm b/guix/packages.scm index 6c697bcc67..3a4f547d6b 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -439,16 +439,26 @@ (define (maybe-add-input-labels inputs) inputs) (else (map add-input-label inputs)))) +(define (add-input-labels . inputs) + "Add labels to all of INPUTS." + (map add-input-label inputs)) + (define-syntax sanitize-inputs ;; This is written as a macro rather than as a 'define-inlinable' procedure ;; because as of Guile 3.0.9, peval can handle (null? '()) but not ;; (null? (list x y z)); that residual 'null?' test contributes to code ;; bloat. - (syntax-rules (quote) + (syntax-rules (quote list) "Sanitize INPUTS by turning it into a list of name/package tuples if it's not already the case." ((_ '()) '()) - ((_ inputs) (maybe-add-input-labels inputs)))) + ((_ (list args ...)) + ;; As of 3.0.9, (list ...) is open-coded, which can lead to a long list + ;; of instructions. To reduce code bloat in package modules where input + ;; fields may create such lists, move list allocation to the callee. + (add-input-labels args ...)) + ((_ inputs) + (maybe-add-input-labels inputs)))) (define-syntax current-location-vector (lambda (s)