public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-dev] [PATCH v2 7/7] pypi.eclass: Avoid subshell for extglob setting
Date: Wed, 14 Jun 2023 20:33:55 +0200	[thread overview]
Message-ID: <20230614183452.17770-8-mgorny@gentoo.org> (raw)
In-Reply-To: <20230614183452.17770-1-mgorny@gentoo.org>

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 <mgorny@gentoo.org>
---
 eclass/pypi.eclass | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

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,,}"
 }
 
-- 
2.41.0



      parent reply	other threads:[~2023-06-14 18:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-14 18:33 [gentoo-dev] [PATCH v2 0/7] pypi.eclass: optimize, v2 Michał Górny
2023-06-14 18:33 ` [gentoo-dev] [PATCH v2 1/7] pypi.eclass: Move setting globals to a function Michał Górny
2023-06-14 18:33 ` [gentoo-dev] [PATCH v2 2/7] eclass/tests: Add pypi-bench.sh for global scope logic Michał Górny
2023-06-14 18:33 ` [gentoo-dev] [PATCH v2 3/7] pypi.eclass: Translate version once in the default scenario Michał Górny
2023-06-14 18:33 ` [gentoo-dev] [PATCH v2 4/7] pypi.eclass: Normalize names without subshell Michał Górny
2023-06-14 18:33 ` [gentoo-dev] [PATCH v2 5/7] pypi.eclass: Translate version without subshell in common case Michał Górny
2023-06-14 18:33 ` [gentoo-dev] [PATCH v2 6/7] pypi.eclass: Replace pypi_sdist_url in global scope Michał Górny
2023-06-14 18:33 ` Michał Górny [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230614183452.17770-8-mgorny@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox