diff --git a/src/graph/graph.hh b/src/graph/graph.hh index 06e84780c..c6f088499 100644 --- a/src/graph/graph.hh +++ b/src/graph/graph.hh @@ -132,7 +132,7 @@ struct graph_t for (unsigned i = 0; i < parents.length; i++) { if (parents[i] != parent_index) continue; - parents.remove (i); + parents.remove_unordered (i); break; } } @@ -148,7 +148,7 @@ struct graph_t if ((obj.head + link.position) != offset) continue; - obj.real_links.remove (i); + obj.real_links.remove_unordered (i); return; } } diff --git a/src/graph/markbasepos-graph.hh b/src/graph/markbasepos-graph.hh index 9b01b5d86..36ad7cc06 100644 --- a/src/graph/markbasepos-graph.hh +++ b/src/graph/markbasepos-graph.hh @@ -112,7 +112,7 @@ struct AnchorMatrix : public OT::Layout::GPOS_impl::AnchorMatrix auto& child = c.graph.vertices_[child_idx]; child.remove_parent (this_index); - o.real_links.remove (i); + o.real_links.remove_unordered (i); num_links--; i--; } diff --git a/src/hb-vector.hh b/src/hb-vector.hh index f55ec4643..e43d4fce3 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -391,7 +391,7 @@ struct hb_vector_t return v; } - void remove (unsigned int i) + void remove_ordered (unsigned int i) { if (unlikely (i >= length)) return; @@ -400,6 +400,18 @@ struct hb_vector_t length--; } + template + void remove_unordered (unsigned int i) + { + if (unlikely (i >= length)) + return; + if (i != length - 1) + arrayZ[i] = std::move (arrayZ[length - 1]); + arrayZ[length - 1].~Type (); + length--; + } + void shrink (int size_) { unsigned int size = size_ < 0 ? 0u : (unsigned int) size_; diff --git a/src/test-vector.cc b/src/test-vector.cc index a2b8b631f..65e51c657 100644 --- a/src/test-vector.cc +++ b/src/test-vector.cc @@ -162,7 +162,8 @@ main (int argc, char **argv) v2 = v; - v2.remove (50); + v2.remove_ordered (50); + v2.remove_unordered (50); } {