Re: [PATCH v2 21/24] pack-bitmap: factor out 'add_commit_to_bitmap()'
- From
- Jonathan Tan <jonathantanmy@google.com>
- Date
- Dec 2, 2020, 07:20 UTC
- Message-ID
- <20201202072040.3471532-1-jonathantanmy@google.com>
- In-Reply-To
- <f40a39a48a834443f76015821c0e56021b58fc9a.1605649533.git.me@ttaylorr.com>
Show 30 quoted lines
> +static int add_commit_to_bitmap(struct bitmap_index *bitmap_git,
> + struct bitmap **base,
> + struct commit *commit)
> +{
> + struct ewah_bitmap *or_with = bitmap_for_commit(bitmap_git, commit);
> +
> + if (!or_with)
> + return 0;
> +
> + if (*base == NULL)
> + *base = ewah_to_bitmap(or_with);
> + else
> + bitmap_or_ewah(*base, or_with);
> +
> + return 1;
> +}
> +
> static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
> struct rev_info *revs,
> struct object_list *roots,
> @@ -544,21 +561,10 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
> struct object *object = roots->item;
> roots = roots->next;
>
> - if (object->type == OBJ_COMMIT) {
> - khiter_t pos = kh_get_oid_map(bitmap_git->bitmaps, object->oid);
> -
> - if (pos < kh_end(bitmap_git->bitmaps)) {
> - struct stored_bitmap *st = kh_value(bitmap_git->bitmaps, pos);
> - struct ewah_bitmap *or_with = lookup_stored_bitmap(st);The code from kh_get_oid_map() to lookup_stored_bitmap() here now exists, in add_commit_to_bitmap(), in the form of an invocation to bitmap_for_commit(). Which is correct - that is exactly what bitmap_for_commit() does.
Looks good.