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:
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user