From: Junio C Hamano <gitster@pobox.com>
To: Rafael Silva <rafaeloliveira.cs@gmail.com>
Cc: Miriam Rubio <mirucam@gmail.com>,
git@vger.kernel.org, Pranit Bauva <pranit.bauva@gmail.com>,
Lars Schneider <larsxschneider@gmail.com>,
Christian Couder <chriscool@tuxfamily.org>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Tanushree Tumane <tanushreetumane@gmail.com>
Subject: Re: [PATCH v2 2/7] bisect--helper: reimplement `bisect_replay` shell function in C
Date: Tue, 22 Dec 2020 17:36:52 -0800 [thread overview]
Message-ID: <xmqq4kkdfgln.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <gohp6klfdpbca4.fsf@cpm12071.fritz.box> (Rafael Silva's message of "Wed, 23 Dec 2020 01:23:49 +0100")
Rafael Silva <rafaeloliveira.cs@gmail.com> writes:
> diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
> index b887413d8d..fb15587af8 100644
> --- a/builtin/bisect--helper.c
> +++ b/builtin/bisect--helper.c
> @@ -988,11 +988,8 @@ static int process_replay_file(FILE *fp, struct bisect_terms *terms)
> struct strbuf word = STRBUF_INIT;
> int res = 0;
>
> - while (strbuf_getline(&line, fp) != EOF) {
> + while (!res && strbuf_getline(&line, fp) != EOF)
> res = process_line(terms, &line, &word);
> - if (res)
> - break;
> - }
I do not mind shorter and crisper code, but I somehow find that the
original more cleanly expresses the intent.
"We'll grab input lines one by one until the input runs out" and "we
stop when we see a line that process_line() likes" are conditions
that the loop may stop at two logically distinct levels. You can
conflate them into a single boolean, making it "unless we found a
line the process_line() liked in the previous round, grab the next
line but stop when we ran out the input", and it may make the result
shorter, but it may be easier to follow by normal readers if we kept
them separate, like the original does.
next prev parent reply other threads:[~2020-12-23 1:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-21 16:27 [PATCH v2 0/7] Finish converting git bisect to C part 3 Miriam Rubio
2020-12-21 16:27 ` [PATCH v2 1/7] bisect--helper: reimplement `bisect_log` shell function in C Miriam Rubio
2021-01-18 15:02 ` Johannes Schindelin
2020-12-21 16:27 ` [PATCH v2 2/7] bisect--helper: reimplement `bisect_replay` " Miriam Rubio
2020-12-22 0:15 ` Rafael Silva
2020-12-23 0:23 ` Rafael Silva
2020-12-23 1:36 ` Junio C Hamano [this message]
2020-12-23 10:03 ` Rafael Silva
2020-12-23 20:09 ` Junio C Hamano
2021-01-18 15:59 ` Johannes Schindelin
2020-12-21 16:27 ` [PATCH v2 3/7] bisect--helper: retire `--bisect-write` subcommand Miriam Rubio
2020-12-21 16:27 ` [PATCH v2 4/7] bisect--helper: use `res` instead of return in BISECT_RESET case option Miriam Rubio
2020-12-21 16:27 ` [PATCH v2 5/7] bisect--helper: retire `--bisect-auto-next` subcommand Miriam Rubio
2020-12-21 16:27 ` [PATCH v2 6/7] bisect--helper: reimplement `bisect_skip` shell function in C Miriam Rubio
2021-01-18 16:14 ` Johannes Schindelin
2020-12-21 16:27 ` [PATCH v2 7/7] bisect--helper: retire `--check-and-set-terms` subcommand Miriam Rubio
2021-01-18 16:15 ` [PATCH v2 0/7] Finish converting git bisect to C part 3 Johannes Schindelin
2021-01-18 23:53 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq4kkdfgln.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=larsxschneider@gmail.com \
--cc=mirucam@gmail.com \
--cc=pranit.bauva@gmail.com \
--cc=rafaeloliveira.cs@gmail.com \
--cc=tanushreetumane@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).