From: Junio C Hamano Date: Mon, 1 May 2017 05:14:43 +0000 (+0900) Subject: Merge branch 'jk/prio-queue-avoid-swap-with-self' X-Git-Tag: v2.13.0-rc2~11 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b0f89870ea54b86fb7935f90605d329533849b33?ds=inline;hp=-c Merge branch 'jk/prio-queue-avoid-swap-with-self' Code clean-up. * jk/prio-queue-avoid-swap-with-self: prio_queue_reverse: don't swap elements with themselves --- b0f89870ea54b86fb7935f90605d329533849b33 diff --combined prio-queue.c index 17252d231b,76782b66d4..fc3860fdcb --- a/prio-queue.c +++ b/prio-queue.c @@@ -12,7 -12,9 +12,7 @@@ static inline int compare(struct prio_q static inline void swap(struct prio_queue *queue, int i, int j) { - struct prio_queue_entry tmp = queue->array[i]; - queue->array[i] = queue->array[j]; - queue->array[j] = tmp; + SWAP(queue->array[i], queue->array[j]); } void prio_queue_reverse(struct prio_queue *queue) @@@ -21,7 -23,7 +21,7 @@@ 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); }