From: Junio C Hamano <gitster@pobox.com>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>, git@vger.kernel.org
Subject: Re: [PATCH 5/9] Add "skip_unmerged" option to unpack_trees.
Date: Tue, 05 Feb 2008 15:44:11 -0800 [thread overview]
Message-ID: <7vve536kac.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: alpine.LNX.1.00.0802042127210.13593@iabervon.org
Daniel Barkalow <barkalow@iabervon.org> writes:
> On Tue, 5 Feb 2008, Johannes Schindelin wrote:
>
>> Hi,
>>
>> On Mon, 4 Feb 2008, Daniel Barkalow wrote:
>>
>>
>> > if (any_files) {
>> > - if (o->merge) {
>> > + if (skip_entry) {
>> > + do
>> > + o->pos++;
>> > + while (o->pos < active_nr &&
>> > + !strcmp(active_cache[o->pos]->name,
>> > + src[0]->name));
>> > + } else if (o->merge) {
>>
>> Maybe it is just me, but I would have thought
>>
>> while (++o->pos < active_nr)
>> if (strcmp(active_cache[o->pos]->name,
>> src[0]->name))
>> break;
>>
>> more readable. But that's maybe because I have trouble with do ... while
>> constructs logically (I like to see the loop condition first, then the
>> loop body).
>
> I find yours less readable, because the loop condition is an exceptional
> case (this is the last entry, so we run out of active_cache before finding
> anything else), and you've got the actual effect of the loop in the
> condition instead of the body, and I find using the value of ++x or x++ a
> bit confusing outside of regular idioms. I'd go for:
>
> o->pos++;
> while (o->pos < active_nr &&
> !strcmp(active_cache[o->pos]->name,
> src[0]->name))
> o->pos++;
>
> if you care, though; it's not bad to make it clear we're skipping the
> first of these entries based on a different consideration from the rest
> (the first is the entry we decided to skip, and the rest are ones that
> match it in filename).
The last one is vastly more readable than your original, and
moderately easier to follow than Dscho's, at least to me.
Thanks.
next prev parent reply other threads:[~2008-02-06 0:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-04 18:35 [PATCH 5/9] Add "skip_unmerged" option to unpack_trees Daniel Barkalow
2008-02-05 1:32 ` Johannes Schindelin
2008-02-05 20:38 ` Daniel Barkalow
2008-02-05 22:50 ` Johannes Schindelin
2008-02-05 23:44 ` Junio C Hamano [this message]
2008-02-06 1:05 ` Daniel Barkalow
-- strict thread matches above, loose matches on Subject: below --
2008-01-25 23:24 Daniel Barkalow
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=7vve536kac.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=barkalow@iabervon.org \
--cc=git@vger.kernel.org \
/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