summaryrefslogtreecommitdiffstats
path: root/thirdparty/harfbuzz/src/hb-priority-queue.hh
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2023-09-05 08:27:29 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2023-09-05 08:27:29 +0300
commitafbba19f5dd0866beb88f06232525e96bb687fb8 (patch)
treed0f5e688531d3c5c8c9af2f6cc9e9e1ae6241824 /thirdparty/harfbuzz/src/hb-priority-queue.hh
parent75de1ca76871fdf7f5a9e081aa57ec0e33061107 (diff)
downloadredot-engine-afbba19f5dd0866beb88f06232525e96bb687fb8.tar.gz
HarfBuzz: Update to version 8.1.1
Diffstat (limited to 'thirdparty/harfbuzz/src/hb-priority-queue.hh')
-rw-r--r--thirdparty/harfbuzz/src/hb-priority-queue.hh27
1 files changed, 19 insertions, 8 deletions
diff --git a/thirdparty/harfbuzz/src/hb-priority-queue.hh b/thirdparty/harfbuzz/src/hb-priority-queue.hh
index bf1b282d3d..baac7e1e69 100644
--- a/thirdparty/harfbuzz/src/hb-priority-queue.hh
+++ b/thirdparty/harfbuzz/src/hb-priority-queue.hh
@@ -54,6 +54,9 @@ struct hb_priority_queue_t
bool in_error () const { return heap.in_error (); }
+#ifndef HB_OPTIMIZE_SIZE
+ HB_ALWAYS_INLINE
+#endif
void insert (int64_t priority, unsigned value)
{
heap.push (item_t (priority, value));
@@ -61,6 +64,9 @@ struct hb_priority_queue_t
bubble_up (heap.length - 1);
}
+#ifndef HB_OPTIMIZE_SIZE
+ HB_ALWAYS_INLINE
+#endif
item_t pop_minimum ()
{
assert (!is_empty ());
@@ -106,8 +112,10 @@ struct hb_priority_queue_t
return 2 * index + 2;
}
+ HB_ALWAYS_INLINE
void bubble_down (unsigned index)
{
+ repeat:
assert (index < heap.length);
unsigned left = left_child (index);
@@ -123,19 +131,21 @@ struct hb_priority_queue_t
&& (!has_right || heap.arrayZ[index].first <= heap.arrayZ[right].first))
return;
+ unsigned child;
if (!has_right || heap.arrayZ[left].first < heap.arrayZ[right].first)
- {
- swap (index, left);
- bubble_down (left);
- return;
- }
+ child = left;
+ else
+ child = right;
- swap (index, right);
- bubble_down (right);
+ swap (index, child);
+ index = child;
+ goto repeat;
}
+ HB_ALWAYS_INLINE
void bubble_up (unsigned index)
{
+ repeat:
assert (index < heap.length);
if (index == 0) return;
@@ -145,7 +155,8 @@ struct hb_priority_queue_t
return;
swap (index, parent_index);
- bubble_up (parent_index);
+ index = parent_index;
+ goto repeat;
}
void swap (unsigned a, unsigned b)