1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-21 13:56:11 +02:00

run-command.c: use "opts->processes", not "pp->max_processes"

Neither the "processes" nor "max_processes" members ever change after
their initialization, and they're always equivalent, but some existing
code used "pp->max_processes" when we were already passing the "opts"
to the function, let's use the "opts" directly instead.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2022-10-12 23:02:32 +02:00 committed by Junio C Hamano
parent 2aa8d2259f
commit 9f3df6c048

View File

@ -1599,10 +1599,10 @@ static int pp_start_one(struct parallel_processes *pp,
size_t i;
int code;
for (i = 0; i < pp->max_processes; i++)
for (i = 0; i < opts->processes; i++)
if (pp->children[i].state == GIT_CP_FREE)
break;
if (i == pp->max_processes)
if (i == opts->processes)
BUG("bookkeeping is hard");
code = opts->get_next_task(&pp->children[i].process,
@ -1689,14 +1689,14 @@ static int pp_collect_finished(struct parallel_processes *pp,
const struct run_process_parallel_opts *opts)
{
int code;
size_t i, n = pp->max_processes;
size_t i;
int result = 0;
while (pp->nr_processes > 0) {
for (i = 0; i < pp->max_processes; i++)
for (i = 0; i < opts->processes; i++)
if (pp->children[i].state == GIT_CP_WAIT_CLEANUP)
break;
if (i == pp->max_processes)
if (i == opts->processes)
break;
code = finish_command(&pp->children[i].process);
@ -1725,6 +1725,8 @@ static int pp_collect_finished(struct parallel_processes *pp,
strbuf_addbuf(&pp->buffered_output, &pp->children[i].err);
strbuf_reset(&pp->children[i].err);
} else {
const size_t n = opts->processes;
strbuf_write(&pp->children[i].err, stderr);
strbuf_reset(&pp->children[i].err);
@ -1771,7 +1773,7 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
while (1) {
for (i = 0;
i < spawn_cap && !pp.shutdown &&
pp.nr_processes < pp.max_processes;
pp.nr_processes < opts->processes;
i++) {
code = pp_start_one(&pp, opts);
if (!code)
@ -1785,7 +1787,7 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
if (!pp.nr_processes)
break;
if (opts->ungroup) {
for (size_t i = 0; i < pp.max_processes; i++)
for (size_t i = 0; i < opts->processes; i++)
pp.children[i].state = GIT_CP_WAIT_CLEANUP;
} else {
pp_buffer_stderr(&pp, output_timeout);