Merge branch 'jk/prio-queue-avoid-swap-with-self'
authorJunio C Hamano <gitster@pobox.com>
Mon, 1 May 2017 05:14:43 +0000 (14:14 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 May 2017 05:14:43 +0000 (14:14 +0900)
Code clean-up.

* jk/prio-queue-avoid-swap-with-self:
  prio_queue_reverse: don't swap elements with themselves

prio-queue.c

index 17252d2..fc3860f 100644 (file)
@@ -21,7 +21,7 @@ void prio_queue_reverse(struct prio_queue *queue)
 
        if (queue->compare != NULL)
                die("BUG: prio_queue_reverse() on non-LIFO queue");
-       for (i = 0; i <= (j = (queue->nr - 1) - i); i++)
+       for (i = 0; i < (j = (queue->nr - 1) - i); i++)
                swap(queue, i, j);
 }