diff options
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/graph/graph.hh')
-rw-r--r-- | Build/source/libs/harfbuzz/harfbuzz-src/src/graph/graph.hh | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/graph/graph.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/graph/graph.hh index 38ca5db0961..294a9999185 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/graph/graph.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/graph/graph.hh @@ -173,9 +173,10 @@ struct graph_t void remove_parent (unsigned parent_index) { - for (unsigned i = 0; i < parents.length; i++) + unsigned count = parents.length; + for (unsigned i = 0; i < count; i++) { - if (parents[i] != parent_index) continue; + if (parents.arrayZ[i] != parent_index) continue; parents.remove_unordered (i); break; } @@ -183,7 +184,8 @@ struct graph_t void remove_real_link (unsigned child_index, const void* offset) { - for (unsigned i = 0; i < obj.real_links.length; i++) + unsigned count = obj.real_links.length; + for (unsigned i = 0; i < count; i++) { auto& link = obj.real_links.arrayZ[i]; if (link.objidx != child_index) @@ -199,16 +201,18 @@ struct graph_t void remap_parents (const hb_vector_t<unsigned>& id_map) { - for (unsigned i = 0; i < parents.length; i++) - parents[i] = id_map[parents[i]]; + unsigned count = parents.length; + for (unsigned i = 0; i < count; i++) + parents.arrayZ[i] = id_map[parents.arrayZ[i]]; } void remap_parent (unsigned old_index, unsigned new_index) { - for (unsigned i = 0; i < parents.length; i++) + unsigned count = parents.length; + for (unsigned i = 0; i < count; i++) { - if (parents[i] == old_index) - parents[i] = new_index; + if (parents.arrayZ[i] == old_index) + parents.arrayZ[i] = new_index; } } @@ -328,11 +332,12 @@ struct graph_t bool removed_nil = false; vertices_.alloc (objects.length); vertices_scratch_.alloc (objects.length); - for (unsigned i = 0; i < objects.length; i++) + unsigned count = objects.length; + for (unsigned i = 0; i < count; i++) { // If this graph came from a serialization buffer object 0 is the // nil object. We don't need it for our purposes here so drop it. - if (i == 0 && !objects[i]) + if (i == 0 && !objects.arrayZ[i]) { removed_nil = true; continue; @@ -340,9 +345,9 @@ struct graph_t vertex_t* v = vertices_.push (); if (check_success (!vertices_.in_error ())) - v->obj = *objects[i]; + v->obj = *objects.arrayZ[i]; - check_success (v->link_positions_valid (objects.length, removed_nil)); + check_success (v->link_positions_valid (count, removed_nil)); if (!removed_nil) continue; // Fix indices to account for removed nil object. @@ -579,8 +584,8 @@ struct graph_t const auto& node = object (node_idx); if (offset < node.head || offset >= node.tail) return -1; - unsigned length = node.real_links.length; - for (unsigned i = 0; i < length; i++) + unsigned count = node.real_links.length; + for (unsigned i = 0; i < count; i++) { // Use direct access for increased performance, this is a hot method. const auto& link = node.real_links.arrayZ[i]; @@ -1135,8 +1140,9 @@ struct graph_t size_t total_size_in_bytes () const { size_t total_size = 0; - for (unsigned i = 0; i < vertices_.length; i++) { - size_t size = vertices_[i].obj.tail - vertices_[i].obj.head; + unsigned count = vertices_.length; + for (unsigned i = 0; i < count; i++) { + size_t size = vertices_.arrayZ[i].obj.tail - vertices_.arrayZ[i].obj.head; total_size += size; } return total_size; @@ -1183,21 +1189,23 @@ struct graph_t { if (!parents_invalid) return; - for (unsigned i = 0; i < vertices_.length; i++) - vertices_[i].parents.reset (); + unsigned count = vertices_.length; + + for (unsigned i = 0; i < count; i++) + vertices_.arrayZ[i].parents.reset (); - for (unsigned p = 0; p < vertices_.length; p++) + for (unsigned p = 0; p < count; p++) { - for (auto& l : vertices_[p].obj.all_links ()) + for (auto& l : vertices_.arrayZ[p].obj.all_links ()) { vertices_[l.objidx].parents.push (p); } } - for (unsigned i = 0; i < vertices_.length; i++) + for (unsigned i = 0; i < count; i++) // parents arrays must be accurate or downstream operations like cycle detection // and sorting won't work correctly. - check_success (!vertices_[i].parents.in_error ()); + check_success (!vertices_.arrayZ[i].parents.in_error ()); parents_invalid = false; } @@ -1239,12 +1247,13 @@ struct graph_t // According to https://www3.cs.stonybrook.edu/~rezaul/papers/TR-07-54.pdf // for practical performance this is faster then using a more advanced queue // (such as a fibonacci queue) with a fast decrease priority. - for (unsigned i = 0; i < vertices_.length; i++) + unsigned count = vertices_.length; + for (unsigned i = 0; i < count; i++) { if (i == vertices_.length - 1) - vertices_[i].distance = 0; + vertices_.arrayZ[i].distance = 0; else - vertices_[i].distance = hb_int_max (int64_t); + vertices_.arrayZ[i].distance = hb_int_max (int64_t); } hb_priority_queue_t queue; @@ -1332,10 +1341,11 @@ struct graph_t void remap_all_obj_indices (const hb_vector_t<unsigned>& id_map, hb_vector_t<vertex_t>* sorted_graph) const { - for (unsigned i = 0; i < sorted_graph->length; i++) + unsigned count = sorted_graph->length; + for (unsigned i = 0; i < count; i++) { (*sorted_graph)[i].remap_parents (id_map); - for (auto& link : (*sorted_graph)[i].obj.all_links_writer ()) + for (auto& link : sorted_graph->arrayZ[i].obj.all_links_writer ()) { link.objidx = id_map[link.objidx]; } |