run-command.c: don't copy "data" to "struct parallel_processes"

As with the *_fn members removed in a preceding commit, let's not copy the "data" member of the "struct run_process_parallel_opts" over to the "struct parallel_processes". Now that we're passing the "opts" down there's no reason to do so. This makes the code easier to follow, as we have a "const" attribute on the "struct run_process_parallel_opts", but not "struct parallel_processes". We do not alter the "ungroup" argument, so storing it in the non-const structure would make this control flow less obvious. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Oct 12, 2022 at 23:02 UTC 2aa8d2259ffd477b5d8ff090c90b7d38910b4741
1 file changed +3 -6
run-command.c
+3 -6
@@ -1497,8 +1497,6 @@ enum child_state {
1497 };
1498
1499 struct parallel_processes {
1500 - void *const data;
1501 -
1500 const size_t max_processes;
1501 size_t nr_processes;
1502
@@ -1609,7 +1607,7 @@ static int pp_start_one(struct parallel_processes *pp,
1607
1608 code = opts->get_next_task(&pp->children[i].process,
1609 opts->ungroup ? NULL : &pp->children[i].err,
1612 - pp->data,
1610 + opts->data,
1611 &pp->children[i].data);
1612 if (!code) {
1613 if (!opts->ungroup) {
@@ -1628,7 +1626,7 @@ static int pp_start_one(struct parallel_processes *pp,
1626 if (opts->start_failure)
1627 code = opts->start_failure(opts->ungroup ? NULL :
1628 &pp->children[i].err,
1631 - pp->data,
1629 + opts->data,
1630 pp->children[i].data);
1631 else
1632 code = 0;
@@ -1705,7 +1703,7 @@ static int pp_collect_finished(struct parallel_processes *pp,
1703
1704 if (opts->task_finished)
1705 code = opts->task_finished(code, opts->ungroup ? NULL :
1708 - &pp->children[i].err, pp->data,
1706 + &pp->children[i].err, opts->data,
1707 pp->children[i].data);
1708 else
1709 code = 0;
@@ -1758,7 +1756,6 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
1756 int spawn_cap = 4;
1757 struct parallel_processes pp = {
1758 .max_processes = opts->processes,
1761 - .data = opts->data,
1759 .buffered_output = STRBUF_INIT,
1760 };
1761 /* options */