summaryrefslogtreecommitdiff
path: root/name-hash.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-03-21 21:02:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-03-21 21:02:19 (GMT)
commitc241e285e53bc84def85682eeaa265c1cd99cceb (patch)
tree149c957fa2d297c1a2ddb07e5b459f855eb831d5 /name-hash.c
parent09386fff3370c1833cc8c3ba8bbf70e460fecf17 (diff)
parentc73592812d36ccc7eccfd0489177970d246fa522 (diff)
downloadgit-c241e285e53bc84def85682eeaa265c1cd99cceb.zip
git-c241e285e53bc84def85682eeaa265c1cd99cceb.tar.gz
git-c241e285e53bc84def85682eeaa265c1cd99cceb.tar.bz2
Merge branch 'nd/preallocate-hash'
When we know approximately how many entries we will have in the hash-table, it makes sense to size the hash table to that number from the beginning to avoid unnecessary rehashing. * nd/preallocate-hash: Preallocate hash tables when the number of inserts are known in advance
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 942c459..9bac31a 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;