Skip to content

Commit 16f9b4c

Browse files
jeffhostetlergitster
authored andcommitted
name-hash: specify initial size for istate.dir_hash table
Specify an initial size for the istate.dir_hash HashMap matching the size of the istate.name_hash. Previously hashmap_init() was given 0, causing a 64 bucket hashmap to be created. When working with very large repositories, this would cause numerous rehash() calls to realloc and rebalance the hashmap. This is especially true when the worktree is deep, with many directories containing a few files. Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3b9e3c2 commit 16f9b4c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

name-hash.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ static void lazy_init_name_hash(struct index_state *istate)
120120
return;
121121
hashmap_init(&istate->name_hash, (hashmap_cmp_fn) cache_entry_cmp,
122122
istate->cache_nr);
123-
hashmap_init(&istate->dir_hash, (hashmap_cmp_fn) dir_entry_cmp, 0);
123+
hashmap_init(&istate->dir_hash, (hashmap_cmp_fn) dir_entry_cmp,
124+
istate->cache_nr);
124125
for (nr = 0; nr < istate->cache_nr; nr++)
125126
hash_index_entry(istate, istate->cache[nr]);
126127
istate->name_hash_initialized = 1;

0 commit comments

Comments
 (0)