commit: f83b81eed578ea7bcee6bdcc1f72e233b1b81cd6
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri May 30 17:25:44 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 5 11:22:03 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f83b81ee
phase-helpers.sh: accelerate in_iuse() by wrapping contains_word()
EAPI >=5 implements the in_iuse() function. Accelerate it by having it
call the contains_word() function, as opposed to the has() function. Its
performance should increase markedly.
Note that portage strips the <hyphen-minus> and <plus-sign> characters
in the course of incorporating IUSE into IUSE_EFFECTIVE.
if explicit_iuse is None:
explicit_iuse = frozenset(x.lstrip("+-") for x in iuse.split())
# ...
if eapi_attrs.iuse_effective:
portage_iuse = set(self._iuse_effective)
portage_iuse.update(explicit_iuse)
See-also: 4a4631eef7186c29668a8c049d988b61469940fd
Link: https://github.com/gentoo/portage/pull/458
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/phase-helpers.sh | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index fbda4a29fa..f006aa92e0 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -1118,16 +1118,13 @@ fi
if ___eapi_has_in_iuse; then
in_iuse() {
- local use=${1}
-
- if [[ -z "${use}" ]]; then
- echo "!!! in_iuse() called without a parameter." >&2
- echo "!!! in_iuse <USEFLAG>" >&2
+ if [[ ! $1 ]]; then
+ printf >&2 '!!! %s\n' \
+ "in_iuse() called without a parameter." \
+ "in_iuse <USEFLAG>"
die "in_iuse() called without a parameter"
fi
- local liuse=( ${IUSE_EFFECTIVE} )
-
- has "${use}" "${liuse[@]#[+-]}"
+ contains_word "$1" "${IUSE_EFFECTIVE}"
}
fi