Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Merge branch 'jk/prio-queue-avoid-swap-with-self'
author
Junio C Hamano
<gitster@pobox.com>
Mon, 1 May 2017 05:14:43 +0000
(14:14 +0900)
committer
Junio 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
1
2
prio-queue.c
patch
|
diff1
|
diff2
|
blob
|
history
raw
|
compact
(merge:
d9dfed9
1f9e18b
)
diff --combined
prio-queue.c
index 17252d231b31f2b8d82d7160d7b95709e14779ff,76782b66d4dde5bf01190963b19c403856756860..fc3860fdcb9fc50d4d883e1a8638cca474cfb8d0
---
1
/
prio-queue.c
---
2
/
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);
}