Skip to content

Commit 8357805

Browse files
ttaylorrgitster
authored andcommitted
pack-bitmap: factor out 'add_commit_to_bitmap()'
'find_objects()' currently needs to interact with the bitmaps khash pretty closely. To make 'find_objects()' read a little more straightforwardly, remove some of the khash-level details into a new function that describes what it does: 'add_commit_to_bitmap()'. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 98c31f3 commit 8357805

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

pack-bitmap.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,23 @@ static int should_include(struct commit *commit, void *_data)
521521
return 1;
522522
}
523523

524+
static int add_commit_to_bitmap(struct bitmap_index *bitmap_git,
525+
struct bitmap **base,
526+
struct commit *commit)
527+
{
528+
struct ewah_bitmap *or_with = bitmap_for_commit(bitmap_git, commit);
529+
530+
if (!or_with)
531+
return 0;
532+
533+
if (*base == NULL)
534+
*base = ewah_to_bitmap(or_with);
535+
else
536+
bitmap_or_ewah(*base, or_with);
537+
538+
return 1;
539+
}
540+
524541
static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
525542
struct rev_info *revs,
526543
struct object_list *roots,
@@ -544,21 +561,10 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
544561
struct object *object = roots->item;
545562
roots = roots->next;
546563

547-
if (object->type == OBJ_COMMIT) {
548-
khiter_t pos = kh_get_oid_map(bitmap_git->bitmaps, object->oid);
549-
550-
if (pos < kh_end(bitmap_git->bitmaps)) {
551-
struct stored_bitmap *st = kh_value(bitmap_git->bitmaps, pos);
552-
struct ewah_bitmap *or_with = lookup_stored_bitmap(st);
553-
554-
if (base == NULL)
555-
base = ewah_to_bitmap(or_with);
556-
else
557-
bitmap_or_ewah(base, or_with);
558-
559-
object->flags |= SEEN;
560-
continue;
561-
}
564+
if (object->type == OBJ_COMMIT &&
565+
add_commit_to_bitmap(bitmap_git, &base, (struct commit *)object)) {
566+
object->flags |= SEEN;
567+
continue;
562568
}
563569

564570
object_list_insert(object, &not_mapped);

0 commit comments

Comments
 (0)