From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C494D15800A for ; Tue, 13 Jun 2023 06:48:47 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 425C6E099F; Tue, 13 Jun 2023 06:47:51 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DC93AE099B for ; Tue, 13 Jun 2023 06:47:50 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH 3/7] pypi.eclass: Translate version once in the default scenario Date: Tue, 13 Jun 2023 08:45:03 +0200 Message-ID: <20230613064742.413335-4-mgorny@gentoo.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230613064742.413335-1-mgorny@gentoo.org> References: <20230613064742.413335-1-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: efe93b6f-914b-44d5-b89b-b940f810e541 X-Archives-Hash: df7dd4d6486b48d6534622117dba7da6 Instead of translating version two times, once in pypi_sdist_url and then when setting S, do it once and store the result. This gives roughly 371 ops / s, i.e. a 13% speedup. Signed-off-by: Michał Górny --- eclass/pypi.eclass | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/eclass/pypi.eclass b/eclass/pypi.eclass index 732b0c6184ef..a8a179d5a3a4 100644 --- a/eclass/pypi.eclass +++ b/eclass/pypi.eclass @@ -226,12 +226,14 @@ pypi_wheel_url() { # @DESCRIPTION: # Set global variables, SRC_URI and S. _pypi_set_globals() { + local version=$(pypi_translate_version "${PV}") + if [[ ${PYPI_NO_NORMALIZE} ]]; then - SRC_URI="$(pypi_sdist_url --no-normalize)" - S="${WORKDIR}/${PYPI_PN}-$(pypi_translate_version "${PV}")" + SRC_URI="$(pypi_sdist_url --no-normalize "${PYPI_PN}" "${version}")" + S="${WORKDIR}/${PYPI_PN}-${version}" else - SRC_URI="$(pypi_sdist_url)" - S="${WORKDIR}/$(pypi_normalize_name "${PYPI_PN}")-$(pypi_translate_version "${PV}")" + SRC_URI="$(pypi_sdist_url "${PYPI_PN}" "${version}")" + S="${WORKDIR}/$(pypi_normalize_name "${PYPI_PN}")-${version}" fi } -- 2.41.0