diff options
Diffstat (limited to 'src/hb-priority-queue.hh')
-rw-r--r-- | src/hb-priority-queue.hh | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/hb-priority-queue.hh b/src/hb-priority-queue.hh index ac76b7d95..ffb86e30a 100644 --- a/src/hb-priority-queue.hh +++ b/src/hb-priority-queue.hh @@ -63,9 +63,7 @@ struct hb_priority_queue_t heap.arrayZ[0] = heap.arrayZ[heap.length - 1]; heap.shrink (heap.length - 1); - - if (!is_empty ()) - bubble_down (0); + bubble_down (0); return result; } @@ -102,7 +100,7 @@ struct hb_priority_queue_t void bubble_down (unsigned index) { - assert (index < heap.length); + assert (index <= heap.length); unsigned left = left_child (index); unsigned right = right_child (index); @@ -114,7 +112,7 @@ struct hb_priority_queue_t bool has_right = right < heap.length; if (heap.arrayZ[index].first <= heap.arrayZ[left].first - && (!has_right || heap.arrayZ[index].first <= heap.arrayZ[right].first)) + && (!has_right || heap[index].first <= heap.arrayZ[right].first)) return; if (!has_right || heap.arrayZ[left].first < heap.arrayZ[right].first) @@ -130,7 +128,7 @@ struct hb_priority_queue_t void bubble_up (unsigned index) { - assert (index < heap.length); + assert (index <= heap.length); if (index == 0) return; @@ -144,8 +142,8 @@ struct hb_priority_queue_t void swap (unsigned a, unsigned b) { - assert (a < heap.length); - assert (b < heap.length); + assert (a <= heap.length); + assert (b <= heap.length); hb_swap (heap.arrayZ[a], heap.arrayZ[b]); } }; |