git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/1] t/perf: avoid unnecessary test_export() recursion

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Dec 20, 2020, 21:27 UTC
Message-ID
<20201220212740.44273-1-sunshine@sunshineco.com>
In-Reply-To
<20201216073907.62591-1-sunshine@sunshineco.com>

test_export() has been self-recursive since its inception even though a simple for-loop would have served just as well to append its arguments to the `test_export_` variable separated by the pipe character "|". Recently `test_export_` was changed instead to a space-separated list of tokens to be exported, an operation which can be accomplished via a single simple assignment, with no need for looping or recursion. Therefore, simplify the implementation.

While at it, take advantage of the fact that variable names to be exported are shell identifiers, thus won't be composed of special characters or whitespace, thus simple a `$*` can be used rather than magical `"$@"`.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---

This is a follow-up to [1] as discussed in [2]. It applies cleanly atop 'es/perf-export-fix' and 'master'.

[1]: https://lore.kernel.org/git/20201216073907.62591-1-sunshine@sunshineco.com/ [2]: https://lore.kernel.org/git/CAPig+cR+4Wh4Sgk6UhUML4SHqaQsvYmw_77ih+oec2YmqQJCCg@mail.gmail.com/

t/perf/perf-lib.sh | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
index 22d727cef8..e385c6896f 100644
--- a/t/perf/perf-lib.sh
+++ b/t/perf/perf-lib.sh
@@ -147,10 +147,7 @@ test_run_perf_ () {
 	"$GTIME" -f "%E %U %S" -o test_time.$i "$SHELL" -c '
 . '"$TEST_DIRECTORY"/test-lib-functions.sh'
 test_export () {
-	[ $# != 0 ] || return 0
-	test_export_="$test_export_ $1"
-	shift
-	test_export "$@"
+	test_export_="$test_export_ $*"
 }
 '"$1"'
 ret=$?
-- 
2.30.0.rc1.243.g5298b911bd
Previous: Eric Sunshine
Message 8 of 8 in “t/perf: fix test_export() failure with BSD `sed`”
  1. t/perf: fix test_export() failure with BSD `sed`Eric Sunshine, Dec 16, 2020
  2. Junio C HamanoDec 16, 2020
  3. Eric SunshineDec 16, 2020
  4. Jeff KingDec 18, 2020
  5. Eric SunshineDec 18, 2020
  6. Jeff KingDec 18, 2020
  7. Eric SunshineDec 21, 2020
  8. 2/1 t/perf: avoid unnecessary test_export() recursionEric Sunshine, Dec 20, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.