diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2022-10-12 23:02:32 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-10-12 23:12:42 +0200 |
commit | 9f3df6c0487bde80626ea2f367f9850e1758720b (patch) | |
tree | 6e1ed8927c2fa2d890397be802b110dcb48d479c /run-command.c | |
parent | run-command.c: don't copy "data" to "struct parallel_processes" (diff) | |
download | git-9f3df6c0487bde80626ea2f367f9850e1758720b.tar.xz git-9f3df6c0487bde80626ea2f367f9850e1758720b.zip |
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>
Diffstat (limited to 'run-command.c')
-rw-r--r-- | run-command.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/run-command.c b/run-command.c index d382c42f82..719a5b58e2 100644 --- a/run-command.c +++ b/run-command.c @@ -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); |