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 493BB158008 for ; Thu, 15 Jun 2023 15:54:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 57527E09E0; Thu, 15 Jun 2023 15:52:57 +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 10E5CE09DD for ; Thu, 15 Jun 2023 15:52:57 +0000 (UTC) From: Sam James To: gentoo-dev@lists.gentoo.org Cc: ruby@gentoo.org, Sam James Subject: [gentoo-dev] [PATCH 05/11] ruby-ng.eclass: optimize: avoid subshells for ruby_implementations_depend, ruby_get_use_targets Date: Thu, 15 Jun 2023 16:52:32 +0100 Message-ID: <20230615155240.589982-5-sam@gentoo.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230615155240.589982-1-sam@gentoo.org> References: <20230615155240.589982-1-sam@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-Transfer-Encoding: 8bit X-Archives-Salt: 21194719-56f6-41f0-b8eb-5e303077d317 X-Archives-Hash: 5f87d07ca4941a20807eaaa8aeb3e312 We go from 2.5s -> 1.9s to source dev-ruby/*. Bug: https://bugs.gentoo.org/908465 Signed-off-by: Sam James --- eclass/ruby-ng.eclass | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass index cf66fcec2f05d..6c5666ddeabb0 100644 --- a/eclass/ruby-ng.eclass +++ b/eclass/ruby-ng.eclass @@ -325,9 +325,20 @@ ruby_get_use_implementations() { ruby_get_use_targets() { debug-print-function ${FUNCNAME} "${@}" - _ruby_get_all_impls + _ruby_get_use_targets + echo "${_RUBY_GET_USE_TARGETS}" +} + +# @FUNCTION: _ruby_get_use_targets +# @INTERNAL +# @DESCRIPTION: +# Gets an array of ruby use targets that the ebuild sets +_RUBY_GET_USE_TARGETS="" +_ruby_get_use_targets() { + debug-print-function ${FUNCNAME} "${@}" + local impls="${_RUBY_GET_ALL_IMPLS[@]}" - echo "${impls//ruby/ruby_targets_ruby}" + _RUBY_GET_USE_TARGETS="${impls//ruby/ruby_targets_ruby}" } # @FUNCTION: ruby_implementations_depend @@ -346,27 +357,36 @@ ruby_get_use_targets() { # ... # DEPEND="ruby? ( $(ruby_implementations_depend) )" # RDEPEND="${DEPEND}" +_RUBY_IMPLEMENTATIONS_DEPEND="" ruby_implementations_depend() { debug-print-function ${FUNCNAME} "${@}" + _ruby_implementations_depend + echo "${_RUBY_IMPLEMENTATIONS_DEPEND}" +} + +_ruby_implementations_depend() { + local depend _ruby_implementation for _ruby_implementation in "${_RUBY_GET_ALL_IMPLS[@]}"; do depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" done - echo "${depend}" + _RUBY_IMPLEMENTATIONS_DEPEND="${depend}" } _ruby_get_all_impls +_ruby_get_use_targets +_ruby_implementations_depend -IUSE+=" $(ruby_get_use_targets)" +IUSE+=" ${_RUBY_GET_USE_TARGETS}" # If you specify RUBY_OPTIONAL you also need to take care of # ruby useflag and dependency. if [[ ${RUBY_OPTIONAL} != yes ]]; then - DEPEND="${DEPEND} $(ruby_implementations_depend)" - RDEPEND="${RDEPEND} $(ruby_implementations_depend)" - REQUIRED_USE+=" || ( $(ruby_get_use_targets) )" + DEPEND="${DEPEND} ${_RUBY_IMPLEMENTATIONS_DEPEND}" + RDEPEND="${RDEPEND} ${_RUBY_IMPLEMENTATIONS_DEPEND}" + REQUIRED_USE+=" || ( ${_RUBY_GET_USE_TARGETS} )" case ${EAPI} in 6) ;; - *) BDEPEND="${BDEPEND} $(ruby_implementations_depend)" ;; + *) BDEPEND="${BDEPEND} ${_RUBY_IMPLEMENTATIONS_DEPEND}" ;; esac fi -- 2.41.0