All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rafael Silva <rafaeloliveira.cs@gmail.com>
To: Junio C Hamano <gitster@pobox.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: Wed, 23 Dec 2020 11:03:04 +0100	[thread overview]
Message-ID: <gohp6k35zw6drc.fsf@cpm12071.fritz.box> (raw)
In-Reply-To: <xmqq4kkdfgln.fsf@gitster.c.googlers.com>


Junio C Hamano writes:

> 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.

That's a good point (and nice explanation, by the way). Before I was
thinking more on the line "while we do not found a good line from
process_line() and we do not finish processing the file, let's go to
the next line" which lead me to proposed changes for shorten the code.

However, after your explanation, I can see now and agree the original
does seems easier to follow and we can as it is.

-- 
Thanks
Rafael

  reply	other threads:[~2020-12-23 10:04 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
2020-12-23 10:03       ` Rafael Silva [this message]
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=gohp6k35zw6drc.fsf@cpm12071.fritz.box \
    --to=rafaeloliveira.cs@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=larsxschneider@gmail.com \
    --cc=mirucam@gmail.com \
    --cc=pranit.bauva@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.