* Increase the size of the hash map stored in obj_hash to the next * power of 2 (but at least 32). Copy the existing values to the new * hash map. */
| 123 | * hash map. |
| 124 | */ |
| 125 | static void grow_object_hash(struct repository *r) |
| 126 | { |
| 127 | int i; |
| 128 | /* |
| 129 | * Note that this size must always be power-of-2 to match hash_obj |
| 130 | * above. |
| 131 | */ |
| 132 | int new_hash_size = r->parsed_objects->obj_hash_size < 32 ? 32 : 2 * r->parsed_objects->obj_hash_size; |
| 133 | struct object **new_hash; |
| 134 | |
| 135 | CALLOC_ARRAY(new_hash, new_hash_size); |
| 136 | for (i = 0; i < r->parsed_objects->obj_hash_size; i++) { |
| 137 | struct object *obj = r->parsed_objects->obj_hash[i]; |
| 138 | |
| 139 | if (!obj) |
| 140 | continue; |
| 141 | insert_obj_hash(obj, new_hash, new_hash_size); |
| 142 | } |
| 143 | free(r->parsed_objects->obj_hash); |
| 144 | r->parsed_objects->obj_hash = new_hash; |
| 145 | r->parsed_objects->obj_hash_size = new_hash_size; |
| 146 | } |
| 147 | |
| 148 | void *create_object(struct repository *r, const struct object_id *oid, void *o) |
| 149 | { |
no test coverage detected