chiark / gitweb /
prioq: never shuffle identical entries
authorDavid Herrmann <dh.herrmann@gmail.com>
Tue, 29 Sep 2015 18:41:29 +0000 (20:41 +0200)
committerSven Eden <yamakuzure@gmx.net>
Wed, 29 Mar 2017 08:45:10 +0000 (10:45 +0200)
Skip shuffling identical entries in shuffle_up(), just like we already do
in shuffle_down().

src/basic/prioq.c

index b89888b..5e567b1 100644 (file)
@@ -101,7 +101,7 @@ static unsigned shuffle_up(Prioq *q, unsigned idx) {
 
                 k = (idx-1)/2;
 
-                if (q->compare_func(q->items[k].data, q->items[idx].data) < 0)
+                if (q->compare_func(q->items[k].data, q->items[idx].data) <= 0)
                         break;
 
                 swap(q, idx, k);