Re: [PATCH 1/1] builtin/pack-objects.c: avoid iterating all refs
- From
Jeff King <peff@peff.net>
- Date
- Jan 19, 2021, 23:15 UTC
- Message-ID
- <YAdn/zdQP1Hz70ba@coredump.intra.peff.net>
- In-Reply-To
- <20210119143348.27535-2-jacob@gitlab.com>
On Tue, Jan 19, 2021 at 03:33:48PM +0100, Jacob Vosmaer wrote:
Show 7 quoted lines
> In git-pack-objects, we iterate over all the tags if the --include-tag
> option is passed on the command line. For some reason this uses
> for_each_ref which is expensive if the repo has many refs. We should
> use a prefix iterator instead.
> [...]
> - for_each_ref(add_ref_tag, NULL);
> + for_each_fullref_in("refs/tags/", add_ref_tag, NULL, 0);Yeah, this is trivially correct, since the first thing we check in add_ref_tag() is whether it starts with refs/tags/. It would be safe to remove that check as part of this patch (and unlike the multi-prefix one, I am comfortable assuming that for_each_fullref_in() will not return anything outside of the prefix).
I also wondered if we could just use for_each_ref_in() here, but I think we are better having the full refname to feed to peel_ref().
-Peff