aboutsummaryrefslogtreecommitdiffstats
path: root/prio-queue.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-07-21 14:45:01 -0700
committerJunio C Hamano <gitster@pobox.com>2025-07-21 14:45:01 -0700
commit03dce625bff6598e7f77d9f4a4a25d0288e5e5a8 (patch)
tree6df2d5acf8ba19ff8894e9a6a6ee58b5a8743a4e /prio-queue.h
parentMerge branch 'bc/contribution-under-non-real-names' into next (diff)
parentprio-queue: add prio_queue_replace() (diff)
downloadgit-03dce625bff6598e7f77d9f4a4a25d0288e5e5a8.tar.gz
git-03dce625bff6598e7f77d9f4a4a25d0288e5e5a8.zip
Merge branch 'rs/pop-recent-commit-with-prio-queue' into next
The pop_most_recent_commit() function can have quite expensive worst case performance characteristics, which has been optimized by using prio-queue data structure. * rs/pop-recent-commit-with-prio-queue: prio-queue: add prio_queue_replace() commit: use prio_queue_replace() in pop_most_recent_commit(),MIME-Version: 1.0 commit: convert pop_most_recent_commit() to prio_queue
Diffstat (limited to 'prio-queue.h')
-rw-r--r--prio-queue.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/prio-queue.h b/prio-queue.h
index 38d032636d..da7fad2f1f 100644
--- a/prio-queue.h
+++ b/prio-queue.h
@@ -52,6 +52,14 @@ void *prio_queue_get(struct prio_queue *);
*/
void *prio_queue_peek(struct prio_queue *);
+/*
+ * Replace the "thing" that compares the smallest with a new "thing",
+ * like prio_queue_get()+prio_queue_put() would do, but in a more
+ * efficient way. Does the same as prio_queue_put() if the queue is
+ * empty.
+ */
+void prio_queue_replace(struct prio_queue *queue, void *thing);
+
void clear_prio_queue(struct prio_queue *);
/* Reverse the LIFO elements */