Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-03-17 07:28:06 +0400
committerJunio C Hamano <gitster@pobox.com>2013-03-17 09:57:29 +0400
commitc73592812d36ccc7eccfd0489177970d246fa522 (patch)
tree1e92b0c8fb8cb4bf5bbb10f38cf695785457b2e7 /name-hash.c
parent03a0fb0ccf48c831060c2243f830b6a12cd8fdf3 (diff)
Preallocate hash tables when the number of inserts are known in advance
This avoids unnecessary re-allocations and reinsertions. On webkit.git (i.e. about 182k inserts to the name hash table), this reduces about 100ms out of 3s user time. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'name-hash.c')
-rw-r--r--name-hash.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/name-hash.c b/name-hash.c
index d8d25c23e9..2a1f108247 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -92,6 +92,8 @@ static void lazy_init_name_hash(struct index_state *istate)
if (istate->name_hash_initialized)
return;
+ if (istate->cache_nr)
+ preallocate_hash(&istate->name_hash, istate->cache_nr);
for (nr = 0; nr < istate->cache_nr; nr++)
hash_index_entry(istate, istate->cache[nr]);
istate->name_hash_initialized = 1;