diff options
author | Michał Górny <mgorny@gentoo.org> | 2023-06-13 07:55:34 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2023-06-15 14:19:26 +0200 |
commit | c84d64b357a7f8eca3f309f8fc773e928f57cc52 (patch) | |
tree | 99b849b2b151964da71605be9f3144df31b1682c | |
parent | pypi.eclass: Replace pypi_sdist_url in global scope (diff) | |
download | gentoo-c84d64b357a7f8eca3f309f8fc773e928f57cc52.tar.gz gentoo-c84d64b357a7f8eca3f309f8fc773e928f57cc52.tar.bz2 gentoo-c84d64b357a7f8eca3f309f8fc773e928f57cc52.zip |
pypi.eclass: Avoid subshell for extglob setting
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>
-rw-r--r-- | eclass/pypi.eclass | 11 |
1 files 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,,}" } |