commit:     406039196feb2c6a04ae21a7b325eb17bee7eda2
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri May 30 07:40:03 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jun  3 13:34:46 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=40603919

phase-helpers.sh: accelerate use() with contains_word()

Accelerate the use() function by having it call the contains_word()
function, as opposed to the has() function. Its performance should
increase markedly. That being said, it remains somewhat hamstrung by the
IUSE checks that are additionally performed. An investigation is
presently underway as to how its approach may be further refined.

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 | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 2aa84b0a9a..fe7a554f93 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -234,7 +234,7 @@ if ___eapi_has_usex; then
 fi
 
 use() {
-       local - IFS invert u=$1
+       local invert u=$1
 
        # If we got something like '!flag', then invert the return value
        if [[ ${u} == !* ]] ; then
@@ -270,8 +270,7 @@ use() {
                fi
        fi
 
-       set -f
-       has "${u}" ${USE}
+       contains_word "${u}" "${USE}"
        (( $? == invert ? 1 : 0 ))
 }
 

Reply via email to