From: Jeff King Date: Tue, 19 Jan 2021 23:15:11 GMT Subject: Re: [PATCH 1/1] builtin/pack-objects.c: avoid iterating all refs Message-ID: In-Reply-To: <20210119143348.27535-2-jacob@gitlab.com> On Tue, Jan 19, 2021 at 03:33:48PM +0100, Jacob Vosmaer wrote: > 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