| 2124 | } |
| 2125 | |
| 2126 | static void add_preferred_base(struct object_id *oid) |
| 2127 | { |
| 2128 | struct pbase_tree *it; |
| 2129 | void *data; |
| 2130 | unsigned long size; |
| 2131 | size_t size_st = 0; |
| 2132 | struct object_id tree_oid; |
| 2133 | |
| 2134 | if (window <= num_preferred_base++) |
| 2135 | return; |
| 2136 | |
| 2137 | data = odb_read_object_peeled(the_repository->objects, oid, |
| 2138 | OBJ_TREE, &size_st, &tree_oid); |
| 2139 | size = cast_size_t_to_ulong(size_st); |
| 2140 | if (!data) |
| 2141 | return; |
| 2142 | |
| 2143 | for (it = pbase_tree; it; it = it->next) { |
| 2144 | if (oideq(&it->pcache.oid, &tree_oid)) { |
| 2145 | free(data); |
| 2146 | return; |
| 2147 | } |
| 2148 | } |
| 2149 | |
| 2150 | CALLOC_ARRAY(it, 1); |
| 2151 | it->next = pbase_tree; |
| 2152 | pbase_tree = it; |
| 2153 | |
| 2154 | oidcpy(&it->pcache.oid, &tree_oid); |
| 2155 | it->pcache.tree_data = data; |
| 2156 | it->pcache.tree_size = size; |
| 2157 | } |
| 2158 | |
| 2159 | static void cleanup_preferred_base(void) |
| 2160 | { |
no test coverage detected