Provide an internal helper to translate versions without a subshell,
and use it in the common case. Now the benchmark gives 685 ops / s,
which means it's another 28% speedup.
Signed-off-by: Michał Górny <
mgorny@gentoo.org>
---
eclass/pypi.eclass | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/eclass/pypi.eclass b/eclass/pypi.eclass
index d79e6f06fc1b..c8ad2e03d6e8 100644
--- a/eclass/pypi.eclass
+++ b/eclass/pypi.eclass
@@ -95,6 +95,19 @@ pypi_normalize_name() {
echo "${_PYPI_NORMALIZED_NAME}"
}
+# @FUNCTION: _pypi_translate_version
+# @USAGE: <version>
+# @DESCRIPTION:
+# Internal version translation function, returns the result
+# via _PYPI_TRANSLATED_VERSION variable.
+_pypi_translate_version() {
+ local version=${1}
+ version=${version/_alpha/a}
+ version=${version/_beta/b}
+ version=${version/_rc/rc}
+ _PYPI_TRANSLATED_VERSION=${version/_p/.post}
+}
+
# @FUNCTION: pypi_translate_version
# @USAGE: <version>
# @DESCRIPTION:
@@ -106,12 +119,9 @@ pypi_normalize_name() {
pypi_translate_version() {
[[ ${#} -ne 1 ]] && die "Usage: ${FUNCNAME} <version>"
- local version=${1}
- version=${version/_alpha/a}
- version=${version/_beta/b}