| 589 | } |
| 590 | |
| 591 | static 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. |