]> git.ipfire.org Git - thirdparty/git.git/commit
prio-queue: add prio_queue_replace()
authorRené Scharfe <l.s.r@web.de>
Fri, 18 Jul 2025 09:39:14 +0000 (11:39 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 22 Jul 2025 14:28:35 +0000 (07:28 -0700)
commit3d5091d232ea991a6a991c86e9fb000f5a9009a0
treecbc48f1816bea87ac7f374d11029cfa1a725a0ff
parentd6ec08788e667d4f556e9c2d97bbd7adb7e582be
prio-queue: add prio_queue_replace()

Add a function to replace the top element of the queue that basically
does the same as prio_queue_get() followed by prio_queue_put(), but
without the work by prio_queue_get() to rebalance the heap.  It can be
used to optimize loops that get one element and then immediately add
another one.  That's common e.g., with commit history traversal, where
we get out a commit and then put in its parents.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
prio-queue.c
prio-queue.h
t/unit-tests/u-prio-queue.c