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
This commit is contained in:
Junio C Hamano
2013-03-21 14:02:19 -07:00
3 changed files with 10 additions and 0 deletions

View File

@ -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;