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>
This commit is contained in:

committed by
Junio C Hamano

parent
03a0fb0ccf
commit
c73592812d
@ -389,6 +389,7 @@ static int find_exact_renames(struct diff_options *options)
|
||||
struct hash_table file_table;
|
||||
|
||||
init_hash(&file_table);
|
||||
preallocate_hash(&file_table, rename_src_nr + rename_dst_nr);
|
||||
for (i = 0; i < rename_src_nr; i++)
|
||||
insert_file_table(&file_table, -1, i, rename_src[i].p->one);
|
||||
|
||||
|
Reference in New Issue
Block a user