Thread (4 messages) 4 messages, 2 authors, 2024-12-27

Re: [PATCH] prio-queue: use size_t rather than int for size

From: Jeff King <hidden>
Date: 2024-12-20 08:53:39

On Fri, Dec 20, 2024 at 03:49:49AM -0500, Jeff King wrote:
-static inline int compare(struct prio_queue *queue, int i, int j)
+static inline int compare(struct prio_queue *queue, size_t i, size_t j)
 {
 	int cmp = queue->compare(queue->array[i].data, queue->array[j].data,
 				 queue->cb_data);
 	if (!cmp)
-		cmp = queue->array[i].ctr - queue->array[j].ctr;
+		cmp = (queue->array[i].ctr > queue->array[j].ctr) -
+	              (queue->array[i].ctr < queue->array[j].ctr);
 	return cmp;
 }
Sorry, just realized that "diff --check" (and apply) complains about the
indentation here. It's a TAB followed by 14 spaces, instead of two TABs
followed by 6 spaces. I guess caused by me lining things up manually.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help