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 55885158008 for ; Thu, 15 Jun 2023 15:53:13 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C6E67E09AE; Thu, 15 Jun 2023 15:52:53 +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 855A4E09A4 for ; Thu, 15 Jun 2023 15:52:53 +0000 (UTC) From: Sam James To: gentoo-dev@lists.gentoo.org Cc: ruby@gentoo.org, Sam James Subject: [gentoo-dev] [PATCH 02/11] ruby-ng.eclass: optimize: use pattern substitution Date: Thu, 15 Jun 2023 16:52:29 +0100 Message-ID: <20230615155240.589982-2-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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 08755b30-bff1-4217-8c81-0b3b4136c626 X-Archives-Hash: 7ee36a7fdf9b61032c4538a8f5d39402 We can save a little bit (consistently a few ms) by using patsubs in some obvious cases. Not really any difference globally, but for sinatra: ``` $ pk pkg source $(pkg) --repo ~/g/ --bench 5s # before dev-ruby/sinatra-3.0.5::/home/sam/g/: mean: 76.25ms, min: 59.23ms, max: 83.674ms, σ = 4.247ms, N = 66 dev-ruby/sinatra-3.0.5-r1::/home/sam/g/: mean: 77.465ms, min: 61.782ms, max: 85.127ms, σ = 3.592ms, N = 65 dev-ruby/sinatra-3.0.6::/home/sam/g/: mean: 80.192ms, min: 60.922ms, max: 84.951ms, σ = 3.899ms, N = 63 dev-ruby/sinatra-2.2.3::/home/sam/g/: mean: 80.389ms, min: 56.818ms, max: 86.915ms, σ = 4.508ms, N = 63 $ pk pkg source $(pkg) --repo ~/g/ --bench 5s # after dev-ruby/sinatra-2.2.3::/home/sam/g/: mean: 66.68ms, min: 56.938ms, max: 74.248ms, σ = 4.832ms, N = 75 dev-ruby/sinatra-3.0.6::/home/sam/g/: mean: 73.618ms, min: 60.153ms, max: 77.978ms, σ = 3.195ms, N = 68 dev-ruby/sinatra-3.0.5::/home/sam/g/: mean: 72.069ms, min: 58.736ms, max: 78.223ms, σ = 3.277ms, N = 70 dev-ruby/sinatra-3.0.5-r1::/home/sam/g/: mean: 73.265ms, min: 60.738ms, max: 81.06ms, σ = 3.227ms, N = 69 ``` Bug: https://bugs.gentoo.org/908465 Signed-off-by: Sam James --- eclass/ruby-ng.eclass | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass index 5a6edb1bf6080..2bf1885d38031 100644 --- a/eclass/ruby-ng.eclass +++ b/eclass/ruby-ng.eclass @@ -183,11 +183,11 @@ _ruby_wrap_conditions() { local conditions="$1" local atoms="$2" - for condition in $conditions; do + for condition in ${conditions}; do atoms="${condition}? ( ${atoms} )" done - echo "$atoms" + echo "${atoms}" } # @FUNCTION: ruby_add_rdepend @@ -322,11 +322,9 @@ ruby_get_use_implementations() { ruby_get_use_targets() { debug-print-function ${FUNCNAME} "${@}" - local t implementation - for implementation in $(_ruby_get_all_impls); do - t+=" ruby_targets_${implementation}" - done - echo $t + + local impls="$(_ruby_get_all_impls)" + echo "${impls//ruby/ruby_targets_ruby}" } # @FUNCTION: ruby_implementations_depend -- 2.41.0