From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1529077-garchives=archives.gentoo.org@lists.gentoo.org>
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 9812A158008
	for <garchives@archives.gentoo.org>; Thu, 15 Jun 2023 12:19:36 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id DCF3BE08F5;
	Thu, 15 Jun 2023 12:19:35 +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 C30CCE08F5
	for <gentoo-commits@lists.gentoo.org>; Thu, 15 Jun 2023 12:19:35 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(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 smtp.gentoo.org (Postfix) with ESMTPS id C461D340E81
	for <gentoo-commits@lists.gentoo.org>; Thu, 15 Jun 2023 12:19:34 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id DCB69A98
	for <gentoo-commits@lists.gentoo.org>; Thu, 15 Jun 2023 12:19:31 +0000 (UTC)
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" <mgorny@gentoo.org>
Message-ID: <1686831566.c84d64b357a7f8eca3f309f8fc773e928f57cc52.mgorny@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
X-VCS-Repository: repo/gentoo
X-VCS-Files: eclass/pypi.eclass
X-VCS-Directories: eclass/
X-VCS-Committer: mgorny
X-VCS-Committer-Name: Michał Górny
X-VCS-Revision: c84d64b357a7f8eca3f309f8fc773e928f57cc52
X-VCS-Branch: master
Date: Thu, 15 Jun 2023 12:19:31 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 0040221f-de57-45bf-aff3-702324a4b037
X-Archives-Hash: 262f343ec802363404860b8a18a342a2

commit:     c84d64b357a7f8eca3f309f8fc773e928f57cc52
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 13 05:55:34 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jun 15 12:19:26 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c84d64b3

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