Skip to content

Commit 2aa8d22

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 357f8e6 commit 2aa8d22

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

run-command.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,8 +1497,6 @@ enum child_state {
14971497
};
14981498

14991499
struct parallel_processes {
1500-
void *const data;
1501-
15021500
const size_t max_processes;
15031501
size_t nr_processes;
15041502

@@ -1609,7 +1607,7 @@ static int pp_start_one(struct parallel_processes *pp,
16091607

16101608
code = opts->get_next_task(&pp->children[i].process,
16111609
opts->ungroup ? NULL : &pp->children[i].err,
1612-
pp->data,
1610+
opts->data,
16131611
&pp->children[i].data);
16141612
if (!code) {
16151613
if (!opts->ungroup) {
@@ -1628,7 +1626,7 @@ static int pp_start_one(struct parallel_processes *pp,
16281626
if (opts->start_failure)
16291627
code = opts->start_failure(opts->ungroup ? NULL :
16301628
&pp->children[i].err,
1631-
pp->data,
1629+
opts->data,
16321630
pp->children[i].data);
16331631
else
16341632
code = 0;
@@ -1705,7 +1703,7 @@ static int pp_collect_finished(struct parallel_processes *pp,
17051703

17061704
if (opts->task_finished)
17071705
code = opts->task_finished(code, opts->ungroup ? NULL :
1708-
&pp->children[i].err, pp->data,
1706+
&pp->children[i].err, opts->data,
17091707
pp->children[i].data);
17101708
else
17111709
code = 0;
@@ -1758,7 +1756,6 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
17581756
int spawn_cap = 4;
17591757
struct parallel_processes pp = {
17601758
.max_processes = opts->processes,
1761-
.data = opts->data,
17621759
.buffered_output = STRBUF_INIT,
17631760
};
17641761
/* options */

0 commit comments

Comments
 (0)