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 981E51582E8 for ; Sun, 19 May 2024 15:27:58 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 48E70E2A08; Sun, 19 May 2024 15:27: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) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2DF27E2A08 for ; Sun, 19 May 2024 15:27:57 +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)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 262DD33BE93 for ; Sun, 19 May 2024 15:27:56 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B11731ADF for ; Sun, 19 May 2024 15:27:54 +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: <1716130578.0fbe3a4835e538969c5818ca6bece91de933a8de.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: 0fbe3a4835e538969c5818ca6bece91de933a8de X-VCS-Branch: master Date: Sun, 19 May 2024 15:27:54 +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: acf3e480-780f-4d5b-9cce-67a6cc4363c1 X-Archives-Hash: 4e56264d0ded784ee566c80659c70d1a commit: 0fbe3a4835e538969c5818ca6bece91de933a8de Author: Kerin Millar plushkava net> AuthorDate: Sun May 19 14:56:18 2024 +0000 Commit: Sam James gentoo org> CommitDate: Sun May 19 14:56:18 2024 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=0fbe3a48 Micro-optimise _print_args() Optimise _print_args() by initialising the ord_by array lazily. 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 0f0aa44..f2e5bb5 100644 --- a/functions.sh +++ b/functions.sh @@ -535,10 +535,6 @@ _is_visible() _print_args() { awk -v q=\' -f - -- "$@" <<-'EOF' BEGIN { - for (i = 1; i < 32; i++) { - char = sprintf("%c", i) - ord_by[char] = i - } argc = ARGC ARGC = 1 for (arg_idx = 1; arg_idx < argc; arg_idx++) { @@ -548,6 +544,12 @@ _print_args() { word = q arg q } else { # Use $'' quoting per Issue 8 + if (ord_by["\001"] == "") { + for (i = 1; i < 32; i++) { + char = sprintf("%c", i) + ord_by[char] = i + } + } word = "$'" for (i = 1; i <= length(arg); i++) { char = substr(arg, i, 1)