From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1524818-garchives=archives.gentoo.org@lists.gentoo.org>
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 0109E15812E
	for <garchives@archives.gentoo.org>; Fri,  2 Jun 2023 21:47:15 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 99838E08C3;
	Fri,  2 Jun 2023 21:47:14 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 7AC5FE08C3
	for <gentoo-commits@lists.gentoo.org>; Fri,  2 Jun 2023 21:47:14 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 7B268341271
	for <gentoo-commits@lists.gentoo.org>; Fri,  2 Jun 2023 21:47:13 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id DB542A5A
	for <gentoo-commits@lists.gentoo.org>; Fri,  2 Jun 2023 21:47:11 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1685742389.d9278cc22a2e84f19bb758b569870470c69562e2.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: app-shells/bash/
X-VCS-Repository: repo/gentoo
X-VCS-Files: app-shells/bash/bash-5.1_p16-r4.ebuild app-shells/bash/bash-5.1_p16-r5.ebuild app-shells/bash/bash-5.2_p15-r3.ebuild app-shells/bash/bash-9999.ebuild
X-VCS-Directories: app-shells/bash/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: d9278cc22a2e84f19bb758b569870470c69562e2
X-VCS-Branch: master
Date: Fri,  2 Jun 2023 21:47:11 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: f63ccfa9-7853-49f0-bf48-78b2cf643c61
X-Archives-Hash: 4a4baec058c45083fdb3a70e53f23c8b

commit:     d9278cc22a2e84f19bb758b569870470c69562e2
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  2 19:59:51 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jun  2 21:46:29 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d9278cc2

app-shells/bash: optimise SRC_URI generation

Thanks to radhermit's new pkgcraft tooling. Also, thanks to ztrawhcse for suggestions.

Before:
```
app-shells/bash-5.2_p15-r3::.: 61.224122ms
app-shells/bash-5.1_p16-r4::.: 65.001125ms
app-shells/bash-5.1_p16-r5::.: 65.480029ms
```

After:
```
app-shells/bash-5.2_p15-r3::/home/sam/g/: 10.449073ms
app-shells/bash-5.1_p16-r4::/home/sam/g/: 10.505063ms
app-shells/bash-5.1_p16-r5::/home/sam/g/: 10.523583ms
```

This also gets us to approximately the same speed (almost within rounding
error) of pre-d3c19b7974aeb4ac2a1351a019e80625b4111c4b (where we removed eval
usage).

Signed-off-by: Sam James <sam <AT> gentoo.org>

 app-shells/bash/bash-5.1_p16-r4.ebuild | 22 ++++++++++++++--------
 app-shells/bash/bash-5.1_p16-r5.ebuild | 22 ++++++++++++++--------
 app-shells/bash/bash-5.2_p15-r3.ebuild | 21 ++++++++++++++-------
 app-shells/bash/bash-9999.ebuild       | 21 ++++++++++++++-------
 4 files changed, 56 insertions(+), 30 deletions(-)

diff --git a/app-shells/bash/bash-5.1_p16-r4.ebuild b/app-shells/bash/bash-5.1_p16-r4.ebuild
index b87757b3ca9e..25028ea0a987 100644
--- a/app-shells/bash/bash-5.1_p16-r4.ebuild
+++ b/app-shells/bash/bash-5.1_p16-r4.ebuild
@@ -45,21 +45,27 @@ if is_release ; then
 		# bash-5.1 -> bash51
 		my_p=${PN}$(ver_rs 1-2 '' $(ver_cut 1-2))
 
-	        patch_url=
+		patch_url=
 		my_patch_index=
 
+		upstream_url_base="mirror://gnu/bash"
+		mirror_url_base="ftp://ftp.cwru.edu/pub/bash"
+
 		for ((my_patch_index=1; my_patch_index <= ${PLEVEL} ; my_patch_index++)) ; do
-			for url in mirror://gnu/${pn} ftp://ftp.cwru.edu/pub/bash ; do
-				patch_url=$(printf "${url}/${PN}-$(ver_cut 1-2)-patches/${my_p}-%03d" ${my_patch_index})
-				SRC_URI+=" ${patch_url}"
-				SRC_URI+=" verify-sig? ( ${patch_url}.sig )"
+			printf -v mangled_patch_ver ${my_p}-%03d ${my_patch_index}
+			patch_url="${upstream_url_base}/${MY_P}-patches/${mangled_patch_ver}"
 
-			done
+			SRC_URI+=" ${patch_url}"
+			SRC_URI+=" verify-sig? ( ${patch_url}.sig )"
+
+			# Add in the mirror URL too.
+			SRC_URI+=" ${patch_url/${upstream_url_base}/${mirror_url_base}}"
+			SRC_URI+=" verify-sig? ( ${patch_url/${upstream_url_base}/${mirror_url_base}} )"
 
-			MY_PATCHES+=( "${DISTDIR}"/$(printf ${my_p}-%03d ${my_patch_index}) )
+			MY_PATCHES+=( "${DISTDIR}"/${mangled_patch_ver} )
 		done
 
-		unset my_pn patch_url my_patch_index
+		unset my_p patch_url my_patch_index upstream_url_base mirror_url_base
 	fi
 else
 	SRC_URI="ftp://ftp.cwru.edu/pub/bash/${MY_P}.tar.gz"

diff --git a/app-shells/bash/bash-5.1_p16-r5.ebuild b/app-shells/bash/bash-5.1_p16-r5.ebuild
index c617e503f113..230aaaf033a5 100644
--- a/app-shells/bash/bash-5.1_p16-r5.ebuild
+++ b/app-shells/bash/bash-5.1_p16-r5.ebuild
@@ -45,21 +45,27 @@ if is_release ; then
 		# bash-5.1 -> bash51
 		my_p=${PN}$(ver_rs 1-2 '' $(ver_cut 1-2))
 
-	        patch_url=
+		patch_url=
 		my_patch_index=
 
+		upstream_url_base="mirror://gnu/bash"
+		mirror_url_base="ftp://ftp.cwru.edu/pub/bash"
+
 		for ((my_patch_index=1; my_patch_index <= ${PLEVEL} ; my_patch_index++)) ; do
-			for url in mirror://gnu/${pn} ftp://ftp.cwru.edu/pub/bash ; do
-				patch_url=$(printf "${url}/${PN}-$(ver_cut 1-2)-patches/${my_p}-%03d" ${my_patch_index})
-				SRC_URI+=" ${patch_url}"
-				SRC_URI+=" verify-sig? ( ${patch_url}.sig )"
+			printf -v mangled_patch_ver ${my_p}-%03d ${my_patch_index}
+			patch_url="${upstream_url_base}/${MY_P}-patches/${mangled_patch_ver}"
 
-			done
+			SRC_URI+=" ${patch_url}"
+			SRC_URI+=" verify-sig? ( ${patch_url}.sig )"
+
+			# Add in the mirror URL too.
+			SRC_URI+=" ${patch_url/${upstream_url_base}/${mirror_url_base}}"
+			SRC_URI+=" verify-sig? ( ${patch_url/${upstream_url_base}/${mirror_url_base}} )"
 
-			MY_PATCHES+=( "${DISTDIR}"/$(printf ${my_p}-%03d ${my_patch_index}) )
+			MY_PATCHES+=( "${DISTDIR}"/${mangled_patch_ver} )
 		done
 
-		unset my_pn patch_url my_patch_index
+		unset my_p patch_url my_patch_index upstream_url_base mirror_url_base
 	fi
 else
 	SRC_URI="ftp://ftp.cwru.edu/pub/bash/${MY_P}.tar.gz"

diff --git a/app-shells/bash/bash-5.2_p15-r3.ebuild b/app-shells/bash/bash-5.2_p15-r3.ebuild
index 7df4466ab275..4d0dbeb3877d 100644
--- a/app-shells/bash/bash-5.2_p15-r3.ebuild
+++ b/app-shells/bash/bash-5.2_p15-r3.ebuild
@@ -53,17 +53,24 @@ elif is_release ; then
 		patch_url=
 		my_patch_index=
 
+		upstream_url_base="mirror://gnu/bash"
+		mirror_url_base="ftp://ftp.cwru.edu/pub/bash"
+
 		for ((my_patch_index=1; my_patch_index <= ${PLEVEL} ; my_patch_index++)) ; do
-			for url in mirror://gnu/${pn} ftp://ftp.cwru.edu/pub/bash ; do
-				patch_url=$(printf "${url}/${PN}-$(ver_cut 1-2)-patches/${my_p}-%03d" ${my_patch_index})
-				SRC_URI+=" ${patch_url}"
-				SRC_URI+=" verify-sig? ( ${patch_url}.sig )"
-			done
+			printf -v mangled_patch_ver ${my_p}-%03d ${my_patch_index}
+			patch_url="${upstream_url_base}/${MY_P}-patches/${mangled_patch_ver}"
+
+			SRC_URI+=" ${patch_url}"
+			SRC_URI+=" verify-sig? ( ${patch_url}.sig )"
+
+			# Add in the mirror URL too.
+			SRC_URI+=" ${patch_url/${upstream_url_base}/${mirror_url_base}}"
+			SRC_URI+=" verify-sig? ( ${patch_url/${upstream_url_base}/${mirror_url_base}} )"
 
-			MY_PATCHES+=( "${DISTDIR}"/$(printf ${my_p}-%03d ${my_patch_index}) )
+			MY_PATCHES+=( "${DISTDIR}"/${mangled_patch_ver} )
 		done
 
-		unset my_pn patch_url my_patch_index
+		unset my_p patch_url my_patch_index upstream_url_base mirror_url_base
 	fi
 else
 	SRC_URI="mirror://gnu/${PN}/${MY_P}.tar.gz ftp://ftp.cwru.edu/pub/bash/${MY_P}.tar.gz"

diff --git a/app-shells/bash/bash-9999.ebuild b/app-shells/bash/bash-9999.ebuild
index 82dfe5fb1c66..af8066bbfd29 100644
--- a/app-shells/bash/bash-9999.ebuild
+++ b/app-shells/bash/bash-9999.ebuild
@@ -53,17 +53,24 @@ elif is_release ; then
 		patch_url=
 		my_patch_index=
 
+		upstream_url_base="mirror://gnu/bash"
+		mirror_url_base="ftp://ftp.cwru.edu/pub/bash"
+
 		for ((my_patch_index=1; my_patch_index <= ${PLEVEL} ; my_patch_index++)) ; do
-			for url in mirror://gnu/${pn} ftp://ftp.cwru.edu/pub/bash ; do
-				patch_url=$(printf "${url}/${PN}-$(ver_cut 1-2)-patches/${my_p}-%03d" ${my_patch_index})
-				SRC_URI+=" ${patch_url}"
-				SRC_URI+=" verify-sig? ( ${patch_url}.sig )"
-			done
+			printf -v mangled_patch_ver ${my_p}-%03d ${my_patch_index}
+			patch_url="${upstream_url_base}/${MY_P}-patches/${mangled_patch_ver}"
+
+			SRC_URI+=" ${patch_url}"
+			SRC_URI+=" verify-sig? ( ${patch_url}.sig )"
+
+			# Add in the mirror URL too.
+			SRC_URI+=" ${patch_url/${upstream_url_base}/${mirror_url_base}}"
+			SRC_URI+=" verify-sig? ( ${patch_url/${upstream_url_base}/${mirror_url_base}} )"
 
-			MY_PATCHES+=( "${DISTDIR}"/$(printf ${my_p}-%03d ${my_patch_index}) )
+			MY_PATCHES+=( "${DISTDIR}"/${mangled_patch_ver} )
 		done
 
-		unset my_pn patch_url my_patch_index
+		unset my_p patch_url my_patch_index upstream_url_base mirror_url_base
 	fi
 else
 	SRC_URI="mirror://gnu/${PN}/${MY_P}.tar.gz ftp://ftp.cwru.edu/pub/bash/${MY_P}.tar.gz"