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 <mgo...@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