From: "René Scharfe" <l.s.r@web.de>
To: "Git List" <git@vger.kernel.org>,
"Derrick Stolee" <derrickstolee@github.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] gc: simplify maintenance_task_pack_refs()
Date: Tue, 4 Oct 2022 18:17:39 +0200 [thread overview]
Message-ID: <ab33f72e-d552-7bd7-bf04-3c476d32b5b6@web.de> (raw)
Pass a constant string array directly to run_command_v_opt() instead of
copying it into a strvec first. This shortens the code and avoids heap
allocations.
Signed-off-by: René Scharfe <l.s.r@web.de>
---
This patch is a bit silly because it doesn't actually fix anything, but
I can't resist pointing out the possible code size reduction. And if
opts becomes used eventually it's probably easier to use the args member
of struct child_process instead of supplying our own strvec.
builtin/gc.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/builtin/gc.c b/builtin/gc.c
index 2753bd15a5..ceff31ea00 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -167,16 +167,9 @@ static void gc_config(void)
struct maintenance_run_opts;
static int maintenance_task_pack_refs(MAYBE_UNUSED struct maintenance_run_opts *opts)
{
- struct strvec pack_refs_cmd = STRVEC_INIT;
- int ret;
+ const char *argv[] = { "pack-refs", "--all", "--prune", NULL };
- strvec_pushl(&pack_refs_cmd, "pack-refs", "--all", "--prune", NULL);
-
- ret = run_command_v_opt(pack_refs_cmd.v, RUN_GIT_CMD);
-
- strvec_clear(&pack_refs_cmd);
-
- return ret;
+ return run_command_v_opt(argv, RUN_GIT_CMD);
}
static int too_many_loose_objects(void)
--
2.37.3
reply other threads:[~2022-10-04 16:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ab33f72e-d552-7bd7-bf04-3c476d32b5b6@web.de \
--to=l.s.r@web.de \
--cc=avarab@gmail.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).