Subject: Re: [PATCH v2] commit-reach: simplify cleanup of remaining bitmaps in ahead_behind()

From: Derrick Stolee <[email-masked]>
Date: Fri, 20 Mar 2026 12:35:40 -0400

On 3/19/2026 1:44 PM, Junio C Hamano wrote:
> René Scharfe <[email-masked]> writes:
> 
>> Don't bother extracting the last few remaining prio_queue items in
>> order when we only want to free their associated bitmaps; just iterate
>> over the item array.

> Quite obvious and straightforward.  Will queue.  Thanks.

>> -	while (prio_queue_peek(&queue)) {
>> -		struct commit *c = prio_queue_get(&queue);
>> -		free_bit_array(c);
>> -	}
>> +	for (size_t i = 0; i < queue.nr; i++)
>> +		free_bit_array(queue.array[i].data);

I like this cleanup quite a bit, thanks! I appreciate your
self-review on the performance side, too. Thinking out loud
like that can help other (e.g. me) avoid similar mistakes in
the future.

Thanks,
-Stolee