From b2559f477a3f8e2bc76140ca2c76d8cc30b5f5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 8 May 2014 17:14:59 +0200 Subject: [PATCH] pack: preallocate a 64-element chain Dependency chains are often large and require a few reallocations. Allocate a 64-element chain before doing anything else to avoid allocations during the loop. This value comes from the stack-allocated one git uses. We still allocate this on the heap, but it does help performance a little bit. --- src/pack.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pack.c b/src/pack.c index a8577d389..664e8efb0 100644 --- a/src/pack.c +++ b/src/pack.c @@ -1236,6 +1236,7 @@ static int pack_dependency_chain(git_dependency_chain *chain_out, struct git_pac if (!p->bases.entries && (cache_init(&p->bases) < 0)) return -1; + git_array_init_to_size(chain, 64); while (!found_base && error == 0) { struct pack_chain_elem *elem; git_pack_cache_entry *cached = NULL;