summaryrefslogtreecommitdiff
path: root/prio-queue.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-06-06 21:58:12 -0700
committerJunio C Hamano <gitster@pobox.com>2013-06-11 15:15:21 -0700
commitda24b1044f7dc85cda52d6423f5a794a7074fbf8 (patch)
tree44abcb499d4bf5ecb64fe1067586aac5569bdcfb /prio-queue.c
parentb4b594a3154078430b04fad4f6ffbed9c7274be5 (diff)
downloadgit-da24b1044f7dc85cda52d6423f5a794a7074fbf8.tar.gz
sort-in-topological-order: use prio-queue
Use the prio-queue data structure to implement a priority queue of commits sorted by committer date, when handling --date-order. The structure can also be used as a simple LIFO stack, which is a good match for --topo-order processing. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'prio-queue.c')
-rw-r--r--prio-queue.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/prio-queue.c b/prio-queue.c
index f2a4973a01..c9f8c6d253 100644
--- a/prio-queue.c
+++ b/prio-queue.c
@@ -2,6 +2,19 @@
#include "commit.h"
#include "prio-queue.h"
+void prio_queue_reverse(struct prio_queue *queue)
+{
+ int i, j;
+
+ if (queue->compare != NULL)
+ die("BUG: prio_queue_reverse() on non-LIFO queue");
+ for (i = 0; i <= (j = (queue->nr - 1) - i); i++) {
+ struct commit *swap = queue->array[i];
+ queue->array[i] = queue->array[j];
+ queue->array[j] = swap;
+ }
+}
+
void clear_prio_queue(struct prio_queue *queue)
{
free(queue->array);