{"thread":{"id":"58563","subject":"[PATCH] gc: simplify maintenance_task_pack_refs()","startedAt":"2022-10-04T16:17:53Z","lastAt":"2022-10-04T16:17:53Z","messageCount":1,"participants":["René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"464182","messageId":"ab33f72e-d552-7bd7-bf04-3c476d32b5b6@web.de","threadId":"58563","inReplyTo":null,"subject":"[PATCH] gc: simplify maintenance_task_pack_refs()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2022-10-04T16:17:39Z","receivedAt":"2022-10-04T16:17:53Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Pass a constant string array directly to run_command_v_opt() instead of\ncopying it into a strvec first.  This shortens the code and avoids heap\nallocations.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\nThis patch is a bit silly because it doesn't actually fix anything, but\nI can't resist pointing out the possible code size reduction.  And if\nopts becomes used eventually it's probably easier to use the args member\nof struct child_process instead of supplying our own strvec.\n\n builtin/gc.c | 11 ++---------\n 1 file changed, 2 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 2753bd15a5..ceff31ea00 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -167,16 +167,9 @@ static void gc_config(void)\n struct maintenance_run_opts;\n static int maintenance_task_pack_refs(MAYBE_UNUSED struct maintenance_run_opts *opts)\n {\n-\tstruct strvec pack_refs_cmd = STRVEC_INIT;\n-\tint ret;\n+\tconst char *argv[] = { \"pack-refs\", \"--all\", \"--prune\", NULL };\n\n-\tstrvec_pushl(&pack_refs_cmd, \"pack-refs\", \"--all\", \"--prune\", NULL);\n-\n-\tret = run_command_v_opt(pack_refs_cmd.v, RUN_GIT_CMD);\n-\n-\tstrvec_clear(&pack_refs_cmd);\n-\n-\treturn ret;\n+\treturn run_command_v_opt(argv, RUN_GIT_CMD);\n }\n\n static int too_many_loose_objects(void)\n--\n2.37.3\n"}]}