From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Kevin Sawicki <kevin@github.com>
Subject: Re: [PATCH 3/4] fetch-pack: match refs exactly
Date: Mon, 12 Dec 2011 19:54:29 -0500 [thread overview]
Message-ID: <20111213005429.GA3812@sigill.intra.peff.net> (raw)
In-Reply-To: <20111213004808.GC3699@sigill.intra.peff.net>
On Mon, Dec 12, 2011 at 07:48:08PM -0500, Jeff King wrote:
> diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
> index 46688dc..6207ecd 100644
> --- a/builtin/fetch-pack.c
> +++ b/builtin/fetch-pack.c
> @@ -556,11 +556,16 @@ static void filter_refs(struct ref **refs, int nr_match, char **match)
> continue;
> }
> else {
> - int order = path_match(ref->name, nr_match, match);
> - if (order) {
> - return_refs[order-1] = ref;
> - continue; /* we will link it later */
> + int i;
> + for (i = 0; i < nr_match; i++) {
> + if (!strcmp(ref->name, match[i])) {
> + match[i][0] = '\0';
> + return_refs[i] = ref;
> + break;
> + }
> }
> + if (i < nr_match)
> + continue; /* we will link it later */
Astute readers may notice that our matching scheme is now something
like:
for ref in refs
for match in matches
strcmp(ref, match)
If you are fetching everything, that's O(n^2) strcmps (where n is the
number of remote refs). If we sorted the match list (the refs list is
already sorted), we could turn it into an O(n lg n) sort+merge. This is
an optimization we couldn't do with the old suffix-matching rule.
I doubt it matters in any practical case. Even for our crazy 100K ref
cases at GitHub, we don't tend to actually fetch all of those at one
time. So it is more like O(n * m), where m is probably in the dozens at
most.
-Peff
next prev parent reply other threads:[~2011-12-13 0:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-13 0:39 [PATCH 0/4] exact ref-matching for fetch-pack Jeff King
2011-12-13 0:41 ` [PATCH 1/4] drop "match" parameter from get_remote_heads Jeff King
2011-12-13 0:44 ` [PATCH 2/4] t5500: give fully-qualified refs to fetch-pack Jeff King
2011-12-13 0:48 ` [PATCH 3/4] fetch-pack: match refs exactly Jeff King
2011-12-13 0:54 ` Jeff King [this message]
2011-12-15 21:46 ` Junio C Hamano
2011-12-13 0:49 ` [PATCH 4/4] connect.c: drop path_match function Jeff King
2011-12-13 3:23 ` Michael Haggerty
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=20111213005429.GA3812@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=kevin@github.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).