From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/2] pack-objects: break out of want_object loop early
Date: Mon, 25 Jul 2016 18:14:11 -0400 [thread overview]
Message-ID: <20160725221411.GA14131@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqbn1l4c87.fsf@gitster.mtv.corp.google.com>
On Mon, Jul 25, 2016 at 02:52:24PM -0700, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> > if (!*found_pack) {
> > ... first find! fill in found pack, etc ...
> > }
> > if (exclude)
> > return 1;
> > if (incremental)
> > return 0;
> > if (!ignore_packed_keep && !local)
> > break; /* effectively return 1, but I think the break is more clear */
> > if (local && !p->pack_local)
> > return 0;
> > if (ignore_packed_keep && p->pack_local && p->pack_keep)
> > return 0;
> >
> > which just bumps it up. I don't think there is a way to make it more
> > elegant, e.g., by only checking ignore_packed_keep once, because we have
> > to distinguish between each condition being set independently, or the
> > case where neither is set.
> >
> > So I stuck the new check at the end, because to me logically it was "can
> > we break out of the loop instead of looking at p->next". But I agree it
> > would be equivalent to place it before the related checks, and I don't
> > mind doing that if you think it's more readable.
>
> I do not mind too much about having to check two bools twice. But
> given that the reason why I was confused was because I didn't see
> why we need to pass the two "return 0" conditions at least once
> before we decide that we do not need the "return 0" thing at all,
> and started constructing a case where this might break by writing
> "Suppose you have two packs, one remote and one local in packed_git
> list in this order, and ..." before I realized that the new "early
> break" can be hoisted up like the above, I definitely feel that "we
> found one, and we aren't conditionally pretending that this thing
> does not need to be packed at all, so return early and say we want
> to pack it" is easier to understand before the two existing "if"
> statements.
Ah, right. Now you had me second-guessing for a moment that there might
be a bad case in hoisting it up where we would want to return 0 but
would break out early to the "return 1".
But it cannot be the case, because the break is mutually exclusive with
the two conditions.
-Peff
next prev parent reply other threads:[~2016-07-25 22:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-25 18:49 [PATCH 0/2] speed up "Counting objects" when there are many packs Jeff King
2016-07-25 18:50 ` [PATCH 1/2] pack-objects: break out of want_object loop early Jeff King
2016-07-25 19:56 ` Junio C Hamano
2016-07-25 21:41 ` Jeff King
2016-07-25 21:52 ` Junio C Hamano
2016-07-25 22:14 ` Jeff King [this message]
2016-07-26 20:38 ` Junio C Hamano
2016-07-26 20:48 ` Jeff King
2016-07-26 21:38 ` Junio C Hamano
2016-07-27 21:13 ` Jeff King
2016-07-27 21:28 ` Junio C Hamano
2016-07-27 22:04 ` Jeff King
2016-07-25 18:50 ` [PATCH 2/2] pack-objects: compute local/ignore_pack_keep early Jeff King
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=20160725221411.GA14131@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).