MCPcopy Create free account
hub / github.com/git/git / lazy_init_name_hash

Function lazy_init_name_hash

name-hash.c:591–620  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

589}
590
591static void lazy_init_name_hash(struct index_state *istate)
592{
593
594 if (istate->name_hash_initialized)
595 return;
596 trace_performance_enter();
597 trace2_region_enter("index", "name-hash-init", istate->repo);
598 hashmap_init(&istate->name_hash, cache_entry_cmp, NULL, istate->cache_nr);
599 hashmap_init(&istate->dir_hash, dir_entry_cmp, NULL, istate->cache_nr);
600
601 if (lookup_lazy_params(istate)) {
602 /*
603 * Disable item counting and automatic rehashing because
604 * we do per-chain (mod n) locking rather than whole hashmap
605 * locking and we need to prevent the table-size from changing
606 * and bucket items from being redistributed.
607 */
608 hashmap_disable_item_counting(&istate->dir_hash);
609 threaded_lazy_init_name_hash(istate);
610 hashmap_enable_item_counting(&istate->dir_hash);
611 } else {
612 int nr;
613 for (nr = 0; nr < istate->cache_nr; nr++)
614 hash_index_entry(istate, istate->cache[nr]);
615 }
616
617 istate->name_hash_initialized = 1;
618 trace2_region_leave("index", "name-hash-init", istate->repo);
619 trace_performance_leave("initialize name hash");
620}
621
622/*
623 * A test routine for t/helper/ sources.

Callers 4

test_lazy_init_name_hashFunction · 0.85
index_dir_findFunction · 0.85
adjust_dirname_caseFunction · 0.85
index_file_existsFunction · 0.85

Calls 7

trace_performance_enterFunction · 0.85
hashmap_initFunction · 0.85
lookup_lazy_paramsFunction · 0.85
hash_index_entryFunction · 0.85

Tested by 1

test_lazy_init_name_hashFunction · 0.68