| 2356 | } |
| 2357 | |
| 2358 | static void reuse_partial_packfile_from_bitmap_1(struct bitmap_index *bitmap_git, |
| 2359 | struct bitmapped_pack *pack, |
| 2360 | struct bitmap *reuse) |
| 2361 | { |
| 2362 | struct bitmap *result = bitmap_git->result; |
| 2363 | struct pack_window *w_curs = NULL; |
| 2364 | size_t pos = pack->bitmap_pos / BITS_IN_EWORD; |
| 2365 | |
| 2366 | if (!pack->bitmap_pos) { |
| 2367 | /* |
| 2368 | * If we're processing the first (in the case of a MIDX, the |
| 2369 | * preferred pack) or the only (in the case of single-pack |
| 2370 | * bitmaps) pack, then we can reuse whole words at a time. |
| 2371 | * |
| 2372 | * This is because we know that any deltas in this range *must* |
| 2373 | * have their bases chosen from the same pack, since: |
| 2374 | * |
| 2375 | * - In the single pack case, there is no other pack to choose |
| 2376 | * them from. |
| 2377 | * |
| 2378 | * - In the MIDX case, the first pack is the preferred pack, so |
| 2379 | * all ties are broken in favor of that pack (i.e. the one |
| 2380 | * we're currently processing). So any duplicate bases will be |
| 2381 | * resolved in favor of the pack we're processing. |
| 2382 | */ |
| 2383 | while (pos < result->word_alloc && |
| 2384 | pos < pack->bitmap_nr / BITS_IN_EWORD && |
| 2385 | result->words[pos] == (eword_t)~0) |
| 2386 | pos++; |
| 2387 | memset(reuse->words, 0xFF, pos * sizeof(eword_t)); |
| 2388 | } |
| 2389 | |
| 2390 | for (; pos < result->word_alloc; pos++) { |
| 2391 | eword_t word = result->words[pos]; |
| 2392 | size_t offset; |
| 2393 | |
| 2394 | for (offset = 0; offset < BITS_IN_EWORD; offset++) { |
| 2395 | size_t bit_pos; |
| 2396 | uint32_t pack_pos; |
| 2397 | off_t ofs; |
| 2398 | |
| 2399 | if (word >> offset == 0) |
| 2400 | break; |
| 2401 | |
| 2402 | offset += ewah_bit_ctz64(word >> offset); |
| 2403 | |
| 2404 | bit_pos = pos * BITS_IN_EWORD + offset; |
| 2405 | if (bit_pos < pack->bitmap_pos) |
| 2406 | continue; |
| 2407 | if (bit_pos >= pack->bitmap_pos + pack->bitmap_nr) |
| 2408 | goto done; |
| 2409 | |
| 2410 | if (bitmap_is_midx(bitmap_git)) { |
| 2411 | uint32_t midx_pos; |
| 2412 | |
| 2413 | midx_pos = pack_pos_to_midx(bitmap_git->midx, bit_pos); |
| 2414 | ofs = nth_midxed_offset(bitmap_git->midx, midx_pos); |
| 2415 |
no test coverage detected