From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id AC9D515806E for ; Fri, 2 Jun 2023 16:06:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E9C6AE092F; Fri, 2 Jun 2023 16:06:23 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A91EFE087F for ; Fri, 2 Jun 2023 16:06:23 +0000 (UTC) From: =?UTF-8?q?Ulrich=20M=C3=BCller?= To: gentoo-dev@lists.gentoo.org Cc: tex@gentoo.org, =?UTF-8?q?Ulrich=20M=C3=BCller?= , Tim Harder Subject: [gentoo-dev] [PATCH 1/3] texlive-module.eclass: Speed up SRC_URI calculation Date: Fri, 2 Jun 2023 18:06:04 +0200 Message-Id: <20230602160606.24894-1-ulm@gentoo.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 63ee5a4a-6fe8-4a5a-bd8b-225be6f10e4d X-Archives-Hash: e6679655b8bbd77d6fefba4ebab274d1 For texlive-latexextra-2021, SRC_URI calculation ran for 37 seconds here. Reduced it to 0.025 seconds (i.e. more than a factor 1000) by using bash arrays and parameter expansion instead of nested loops. Reported-by: Tim Harder Signed-off-by: Ulrich Müller --- eclass/texlive-module.eclass | 39 +++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/eclass/texlive-module.eclass b/eclass/texlive-module.eclass index fea4003c37a8..99a90d91654f 100644 --- a/eclass/texlive-module.eclass +++ b/eclass/texlive-module.eclass @@ -99,32 +99,39 @@ TEXLIVE_DEVS=${TEXLIVE_DEVS:- zlogene dilfridge sam } BDEPEND="${COMMON_DEPEND} app-arch/xz-utils" -for i in ${TEXLIVE_MODULE_CONTENTS}; do - for tldev in ${TEXLIVE_DEVS}; do - SRC_URI="${SRC_URI} https://dev.gentoo.org/~${tldev}/distfiles/texlive/tl-${i}-${PV}.${PKGEXT}" - done +tl_uri_prefix="https://dev.gentoo.org/~@dev@/distfiles/texlive/tl-" +tl_uri_suffix="-${PV}.${PKGEXT}" + +tl_uri=( ${TEXLIVE_MODULE_CONTENTS} ) +tl_uri=( "${tl_uri[@]/%/${tl_uri_suffix}}" ) +for tldev in ${TEXLIVE_DEVS}; do + SRC_URI+=" ${tl_uri[@]/#/${tl_uri_prefix/@dev@/${tldev}}}" done # Forge doc SRC_URI -[[ -n ${TEXLIVE_MODULE_DOC_CONTENTS} ]] && SRC_URI="${SRC_URI} doc? (" -for i in ${TEXLIVE_MODULE_DOC_CONTENTS}; do +if [[ -n ${TEXLIVE_MODULE_DOC_CONTENTS} ]]; then + SRC_URI+=" doc? (" + tl_uri=( ${TEXLIVE_MODULE_DOC_CONTENTS} ) + tl_uri=( "${tl_uri[@]/%/${tl_uri_suffix}}" ) for tldev in ${TEXLIVE_DEVS}; do - SRC_URI="${SRC_URI} https://dev.gentoo.org/~${tldev}/distfiles/texlive/tl-${i}-${PV}.${PKGEXT}" + SRC_URI+=" ${tl_uri[@]/#/${tl_uri_prefix/@dev@/${tldev}}}" done -done -[[ -n ${TEXLIVE_MODULE_DOC_CONTENTS} ]] && SRC_URI="${SRC_URI} )" + SRC_URI+=" )" +fi # Forge source SRC_URI -if [[ -n ${TEXLIVE_MODULE_SRC_CONTENTS} ]] ; then - SRC_URI="${SRC_URI} source? (" - for i in ${TEXLIVE_MODULE_SRC_CONTENTS}; do - for tldev in ${TEXLIVE_DEVS}; do - SRC_URI="${SRC_URI} https://dev.gentoo.org/~${tldev}/distfiles/texlive/tl-${i}-${PV}.${PKGEXT}" - done +if [[ -n ${TEXLIVE_MODULE_SRC_CONTENTS} ]]; then + SRC_URI+=" source? (" + tl_uri=( ${TEXLIVE_MODULE_SRC_CONTENTS} ) + tl_uri=( "${tl_uri[@]/%/${tl_uri_suffix}}" ) + for tldev in ${TEXLIVE_DEVS}; do + SRC_URI+=" ${tl_uri[@]/#/${tl_uri_prefix/@dev@/${tldev}}}" done - SRC_URI="${SRC_URI} )" + SRC_URI+=" )" fi +unset tldev tl_uri tl_uri_prefix tl_uri_suffix + RDEPEND="${COMMON_DEPEND}" IUSE="${IUSE} doc" -- 2.40.1