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) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 752601581D3 for ; Fri, 24 May 2024 01:18:48 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B33B6E2A28; Fri, 24 May 2024 01:18:47 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 8ED85E2A28 for ; Fri, 24 May 2024 01:18:47 +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) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B9EDF342FFB for ; Fri, 24 May 2024 01:18:46 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 20ED41A2E for ; Fri, 24 May 2024 01:18:45 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1716395220.b5feaf2444ae625f5756c7566042d28f81a2cda1.sam@gentoo> Subject: [gentoo-commits] proj/gentoo-functions:master commit in: / X-VCS-Repository: proj/gentoo-functions X-VCS-Files: functions.sh X-VCS-Directories: / X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: b5feaf2444ae625f5756c7566042d28f81a2cda1 X-VCS-Branch: master Date: Fri, 24 May 2024 01:18:45 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 72e86308-7dec-4c5d-8efe-4b51d8e884a8 X-Archives-Hash: 0adc23101a2826d4904dc2947e9eb038 commit: b5feaf2444ae625f5756c7566042d28f81a2cda1 Author: Kerin Millar plushkava net> AuthorDate: Wed May 22 05:54:12 2024 +0000 Commit: Sam James gentoo org> CommitDate: Wed May 22 16:27:00 2024 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=b5feaf24 Micro-optimise the eqatag() argument parsing loop Signed-off-by: Kerin Millar plushkava.net> functions.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/functions.sh b/functions.sh index 98e7a6f..f965534 100644 --- a/functions.sh +++ b/functions.sh @@ -187,7 +187,7 @@ eoutdent() # eqatag() { - local arg argc json positional tag + local arg i json positional tag case ${genfun_has_jq} in 0) @@ -211,11 +211,14 @@ eqatag() if [ "$#" -eq 0 ]; then die "eqatag: no tag specified" fi + positional=0 tag=$1 shift - argc=$# - positional=0 + i=0 for arg; do + if [ "$(( i += 1 ))" -eq 1 ]; then + set -- + fi case ${arg} in [!=/]*=?*) if [ "${positional}" -eq 1 ]; then @@ -234,7 +237,6 @@ eqatag() _throw_invalid_args eqatag "${arg}" esac done - shift "${argc}" json=$( jq -cn '{ eqatag: {