[graph] Pre-alloc priority-heap array

This commit is contained in:
Behdad Esfahbod 2023-11-10 12:24:26 -07:00
parent 29f8d9f795
commit 9c4d3c3c70
2 changed files with 4 additions and 0 deletions

View file

@ -567,6 +567,7 @@ struct graph_t
update_distances ();
hb_priority_queue_t<int64_t> queue;
queue.alloc (vertices_.length);
hb_vector_t<vertex_t> &sorted_graph = vertices_scratch_;
if (unlikely (!check_success (sorted_graph.resize (vertices_.length)))) return;
hb_vector_t<unsigned> id_map;

View file

@ -55,6 +55,9 @@ struct hb_priority_queue_t
bool in_error () const { return heap.in_error (); }
bool alloc (unsigned size)
{ return heap.alloc (size); }
#ifndef HB_OPTIMIZE_SIZE
HB_ALWAYS_INLINE
#endif