Re: [PATCH v2 20/24] pack-bitmap: factor out 'bitmap_for_commit()'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +struct ewah_bitmap *bitmap_for_commit(struct bitmap_index *bitmap_git,
> +				      struct commit *commit)
> +{
> +	khiter_t hash_pos = kh_get_oid_map(bitmap_git->bitmaps,
> +					   commit->object.oid);
> +	if (hash_pos >= kh_end(bitmap_git->bitmaps))
> +		return NULL;
> +	return lookup_stored_bitmap(kh_value(bitmap_git->bitmaps, hash_pos));
> +}

The new function.

>  static int add_to_include_set(struct bitmap_index *bitmap_git,
>  			      struct include_data *data,
> -			      const struct object_id *oid,
> +			      struct commit *commit,
>  			      int bitmap_pos)
>  {
> -	khiter_t hash_pos;
> +	struct ewah_bitmap *partial;
>  
>  	if (data->seen && bitmap_get(data->seen, bitmap_pos))
>  		return 0;
> @@ -476,10 +486,9 @@ static int add_to_include_set(struct bitmap_index *bitmap_git,
>  	if (bitmap_get(data->base, bitmap_pos))
>  		return 0;
>  
> -	hash_pos = kh_get_oid_map(bitmap_git->bitmaps, *oid);
> -	if (hash_pos < kh_end(bitmap_git->bitmaps)) {
> -		struct stored_bitmap *st = kh_value(bitmap_git->bitmaps, hash_pos);
> -		bitmap_or_ewah(data->base, lookup_stored_bitmap(st));
> +	partial = bitmap_for_commit(bitmap_git, commit);
> +	if (partial) {
> +		bitmap_or_ewah(data->base, partial);
>  		return 0;
>  	}

A straightforward mechanical change. The function invocation replaces
conversion from commit to oid (which is why add_to_include_set() now
takes a struct commit * instead of a struct object_id *) and all the
other deleted lines here.

> @@ -1297,12 +1305,9 @@ void test_bitmap_walk(struct rev_info *revs)
>  		bitmap_git->version, bitmap_git->entry_count);
>  
>  	root = revs->pending.objects[0].item;
> -	pos = kh_get_oid_map(bitmap_git->bitmaps, root->oid);
> -
> -	if (pos < kh_end(bitmap_git->bitmaps)) {
> -		struct stored_bitmap *st = kh_value(bitmap_git->bitmaps, pos);
> -		struct ewah_bitmap *bm = lookup_stored_bitmap(st);
> +	bm = bitmap_for_commit(bitmap_git, (struct commit *)root);
>  
> +	if (bm) {
>  		fprintf(stderr, "Found bitmap for %s. %d bits / %08x checksum\n",
>  			oid_to_hex(&root->oid), (int)bm->bit_size, ewah_checksum(bm));
>  

Same here. LGTM.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux