Thread (13 messages) flat view 13 messages, 4 authors, 2021-01-21

Re: [PATCH 1/1] builtin/pack-objects.c: avoid iterating all refs

From: Jeff King <hidden>
Date: 2021-01-19 23:17:00

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help