Re: [PATCH v2 04/18] maintenance: initialize task array
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 23, 2020, 19:57 UTC
- Message-ID
- <xmqqr1t2qa1n.fsf@gitster.c.googlers.com>
- In-Reply-To
- <8e260bccf1a0b6cd799a6bc78798b31ebed8ad7e.1595527000.git.gitgitgadget@gmail.com>
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 12 quoted lines
> +static void initialize_tasks(void)
> +{
> + int i;
> + num_tasks = 0;
> +
> + for (i = 0; i < MAX_NUM_TASKS; i++)
> + tasks[i] = xcalloc(1, sizeof(struct maintenance_task));
> +
> + tasks[num_tasks]->name = "gc";
> + tasks[num_tasks]->fn = maintenance_task_gc;
> + tasks[num_tasks]->enabled = 1;
> + num_tasks++;Are we going to have 47 different tasks initialized by code like this in the future? I would have expected that you'd have a table of tasks that serves as the blueprint copy and copy it to the table to be used if there is some need to mutate the table-to-be-used.
Show 11 quoted lines
> } > > int cmd_maintenance(int argc, const char **argv, const char *prefix) > @@ -751,6 +787,7 @@ int cmd_maintenance(int argc, const char **argv, const char *prefix) > builtin_maintenance_options); > > opts.quiet = !isatty(2); > + initialize_tasks(); > > argc = parse_options(argc, argv, prefix, > builtin_maintenance_options,