git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git List <git@vger.kernel.org>, Jeff King <peff@peff.net>
Subject: Re: [PATCH 3/3] commit: use prio_queue_replace() in pop_most_recent_commit()
Date: Wed, 16 Jul 2025 11:38:46 +0200	[thread overview]
Message-ID: <2cec288f-e632-431d-aba0-e98798b833ad@web.de> (raw)
In-Reply-To: <xmqqh5zdgp6r.fsf@gitster.g>

On 7/15/25 10:43 PM, Junio C Hamano wrote:
> René Scharfe <l.s.r@web.de> writes:
> 
>> diff --git a/commit.c b/commit.c
>> index 0200759aaa..8244221b30 100644
>> --- a/commit.c
>> +++ b/commit.c
>> @@ -742,17 +742,24 @@ void commit_list_sort_by_date(struct commit_list **list)
>>  struct commit *pop_most_recent_commit(struct prio_queue *queue,
>>  				      unsigned int mark)
>>  {
>> -	struct commit *ret = prio_queue_get(queue);
>> +	struct commit *ret = prio_queue_peek(queue);
>> +	int delete_pending = 1;
> 
> Briefly I was puzzled by the name (I would have called first-parent
> since the logic was "we treat first parent specially by using
> replace instead of get/put"), but the variable signals "instead of
> get to remove the item from the queue, we just peeked, so we need to
> remove it later" with its name, which is understandable.

Indeed, we're just interested in the removal part of prio_queue_get()
here, as we have done the cheap half (the peeking) already.  We don't
have a prio_queue_delete().  Adding one would perhaps add some clarity
here, but also widen the interface and probably not bring much of a
performance gain.

So perhaps calling the variable get_pending like the prio_queue_get()
that we end up invoking would reduce the initial puzzlement?

> 
>>  	struct commit_list *parents = ret->parents;
>>  
>>  	while (parents) {
>>  		struct commit *commit = parents->item;
>>  		if (!repo_parse_commit(the_repository, commit) && !(commit->object.flags & mark)) {
>>  			commit->object.flags |= mark;
>> -			prio_queue_put(queue, commit);
>> +			if (delete_pending)
>> +				prio_queue_replace(queue, commit);
>> +			else
>> +				prio_queue_put(queue, commit);
>> +			delete_pending = 0;
>>  		}
>>  		parents = parents->next;
>>  	}
>> +	if (delete_pending)
>> +		prio_queue_get(queue);
>>  	return ret;
>>  }


  reply	other threads:[~2025-07-16  9:38 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-15 14:35 [PATCH 0/3] commit: convert pop_most_recent_commit() to prio_queue René Scharfe
2025-07-15 14:51 ` [PATCH 1/3] " René Scharfe
2025-07-15 19:23   ` Junio C Hamano
2025-07-15 20:47   ` Justin Tobler
2025-07-16  9:39     ` René Scharfe
2025-07-16  5:05   ` Jeff King
2025-07-16  9:39     ` René Scharfe
2025-07-17  8:22       ` René Scharfe
2025-07-19  6:55       ` Jeff King
2025-07-19  6:57         ` Jeff King
2025-07-19 11:15         ` René Scharfe
2025-07-20  0:03           ` Jeff King
2025-07-20  1:22             ` Junio C Hamano
2025-07-16 22:23   ` Junio C Hamano
2025-07-17  8:22     ` René Scharfe
2025-07-15 14:51 ` [PATCH 2/3] prio-queue: add prio_queue_replace() René Scharfe
2025-07-16  5:09   ` Jeff King
2025-07-16  9:38     ` René Scharfe
2025-07-17  9:20       ` René Scharfe
2025-07-19  7:02         ` Jeff King
2025-07-15 14:51 ` [PATCH 3/3] commit: use prio_queue_replace() in pop_most_recent_commit() René Scharfe
2025-07-15 20:43   ` Junio C Hamano
2025-07-16  9:38     ` René Scharfe [this message]
2025-07-16  0:07 ` [PATCH 0/3] commit: convert pop_most_recent_commit() to prio_queue Junio C Hamano
2025-07-16  5:15   ` Jeff King
2025-07-16  9:38     ` René Scharfe
2025-07-19  6:45       ` Jeff King
2025-07-16 14:49     ` Junio C Hamano
2025-07-18  9:09 ` [PATCH v2 " René Scharfe
2025-07-18  9:39   ` [PATCH v2 1/3] " René Scharfe
2025-07-21 14:02     ` Lidong Yan
2025-08-03  9:54       ` René Scharfe
2025-08-03 16:48         ` Junio C Hamano
2025-08-04 19:56           ` René Scharfe
2025-07-18  9:39   ` [PATCH v2 3/3] commit: use prio_queue_replace() in pop_most_recent_commit(),MIME-Version: 1.0 René Scharfe
2025-08-03 11:12     ` Johannes Schindelin
2025-08-03 11:33       ` René Scharfe
2025-07-18  9:39   ` [PATCH v2 2/3] prio-queue: add prio_queue_replace() René Scharfe
2025-07-19  7:04   ` [PATCH v2 0/3] commit: convert pop_most_recent_commit() to prio_queue Jeff King
2025-07-22  6:26   ` SZEDER Gábor
2025-07-22 14:27     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2cec288f-e632-431d-aba0-e98798b833ad@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).