From c84d64b357a7f8eca3f309f8fc773e928f57cc52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Tue, 13 Jun 2023 07:55:34 +0200 Subject: pypi.eclass: Avoid subshell for extglob setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suggested by Eli Schwartz. This gives roughly 5260 ops / s, over 550% speedup. The complete patch series therefore increases the speed from roughly 326 ops / s to 5260 ops / s, making the common case 16 times faster. Closes: https://bugs.gentoo.org/908411 Closes: https://github.com/gentoo/gentoo/pull/31404 Signed-off-by: Michał Górny --- eclass/pypi.eclass | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'eclass/pypi.eclass') diff --git a/eclass/pypi.eclass b/eclass/pypi.eclass index 8911628994eb..8a842c450ebc 100644 --- a/eclass/pypi.eclass +++ b/eclass/pypi.eclass @@ -71,10 +71,13 @@ _PYPI_ECLASS=1 # via _PYPI_NORMALIZED_NAME variable. _pypi_normalize_name() { local name=${1} - local shopt_save=$(shopt -p extglob) - shopt -s extglob - name=${name//+([._-])/_} - ${shopt_save} + if shopt -p -q extglob; then + name=${name//+([._-])/_} + else + shopt -s extglob + name=${name//+([._-])/_} + shopt -u extglob + fi _PYPI_NORMALIZED_NAME="${name,,}" } -- cgit v1.2.3