public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/3] texlive-module.eclass: Speed up SRC_URI calculation
@ 2023-06-02 16:06 Ulrich Müller
  2023-06-02 16:06 ` [gentoo-dev] [PATCH 2/3] texlive-module.eclass: Reduce number of executed external commands Ulrich Müller
  2023-06-02 16:06 ` [gentoo-dev] [PATCH 3/3] texlive-module.eclass: Whitespace Ulrich Müller
  0 siblings, 2 replies; 3+ messages in thread
From: Ulrich Müller @ 2023-06-02 16:06 UTC (permalink / raw
  To: gentoo-dev; +Cc: tex, Ulrich Müller, Tim Harder

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 <radhermit@gentoo.org>
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
---
 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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-02 16:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-02 16:06 [gentoo-dev] [PATCH 1/3] texlive-module.eclass: Speed up SRC_URI calculation Ulrich Müller
2023-06-02 16:06 ` [gentoo-dev] [PATCH 2/3] texlive-module.eclass: Reduce number of executed external commands Ulrich Müller
2023-06-02 16:06 ` [gentoo-dev] [PATCH 3/3] texlive-module.eclass: Whitespace Ulrich Müller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox