diff --git a/src/graph/graph.hh b/src/graph/graph.hh index 7f38b9ca3..0d86ae672 100644 --- a/src/graph/graph.hh +++ b/src/graph/graph.hh @@ -762,14 +762,16 @@ struct graph_t void find_subgraph (unsigned node_idx, hb_set_t& subgraph) { - if (!subgraph.test_and_add (node_idx)) return; + if (subgraph.has (node_idx)) return; + subgraph.add (node_idx); for (const auto& link : vertices_[node_idx].obj.all_links ()) find_subgraph (link.objidx, subgraph); } size_t find_subgraph_size (unsigned node_idx, hb_set_t& subgraph, unsigned max_depth = -1) { - if (!subgraph.test_and_add (node_idx)) return 0; + if (subgraph.has (node_idx)) return 0; + subgraph.add (node_idx); const auto& o = vertices_[node_idx].obj; size_t size = o.tail - o.head; @@ -1157,7 +1159,8 @@ struct graph_t hb_set_t visited; for (unsigned p : vertices_[node_idx].parents) { - if (!visited.test_and_add (p)) continue; + if (visited.has (p)) continue; + visited.add (p); // Only real links can be wide for (const auto& l : vertices_[p].obj.real_links) @@ -1361,10 +1364,14 @@ struct graph_t hb_set_t& connected) { if (unlikely (!check_success (!visited.in_error ()))) return; - if (!visited.test_and_add (start_idx)) return; + if (visited.has (start_idx)) return; + visited.add (start_idx); - if (targets.test_and_del (start_idx)) + if (targets.has (start_idx)) + { + targets.del (start_idx); connected.add (start_idx); + } const auto& v = vertices_[start_idx]; diff --git a/src/hb-bit-page.hh b/src/hb-bit-page.hh index a58150ff7..e1826e12a 100644 --- a/src/hb-bit-page.hh +++ b/src/hb-bit-page.hh @@ -115,31 +115,6 @@ struct hb_bit_page_t void set (hb_codepoint_t g, bool value) { if (value) add (g); else del (g); } bool get (hb_codepoint_t g) const { return elt (g) & mask (g); } - bool test_and_add (hb_codepoint_t g) - { - elt_t *e = &elt (g); - elt_t m = mask (g); - - bool ret = !(*e & m); - if (ret) - { - *e |= m; dirty (); - } - return ret; - } - bool test_and_del (hb_codepoint_t g) - { - elt_t *e = &elt (g); - elt_t m = mask (g); - - bool ret = *e & m; - if (ret) - { - *e &= ~m; dirty (); - } - return ret; - } - void add_range (hb_codepoint_t a, hb_codepoint_t b) { elt_t *la = &elt (a); diff --git a/src/hb-bit-set-invertible.hh b/src/hb-bit-set-invertible.hh index 7cd6e7082..e765a479a 100644 --- a/src/hb-bit-set-invertible.hh +++ b/src/hb-bit-set-invertible.hh @@ -104,8 +104,6 @@ struct hb_bit_set_invertible_t void add (hb_codepoint_t g) { unlikely (inverted) ? s.del (g) : s.add (g); } - bool test_and_add (hb_codepoint_t g) { return unlikely (inverted) ? s.test_and_del (g) : s.test_and_add (g); } - bool test_and_del (hb_codepoint_t g) { return unlikely (inverted) ? s.test_and_add (g) : s.test_and_del (g); } bool add_range (hb_codepoint_t a, hb_codepoint_t b) { return unlikely (inverted) ? ((void) s.del_range (a, b), true) : s.add_range (a, b); } diff --git a/src/hb-bit-set.hh b/src/hb-bit-set.hh index de5c4ea70..17eb06541 100644 --- a/src/hb-bit-set.hh +++ b/src/hb-bit-set.hh @@ -154,22 +154,6 @@ struct hb_bit_set_t page_t *page = page_for (g, true); if (unlikely (!page)) return; page->add (g); } - bool test_and_add (hb_codepoint_t g) - { - if (unlikely (!successful)) return false; - if (unlikely (g == INVALID)) return false; - dirty (); - page_t *page = page_for (g, true); if (unlikely (!page)) return false; - return page->test_and_add (g); - } - bool test_and_del (hb_codepoint_t g) - { - if (unlikely (!successful)) return false; - if (unlikely (g == INVALID)) return false; - dirty (); - page_t *page = page_for (g); if (!page) return false; - return page->test_and_del (g); - } bool add_range (hb_codepoint_t a, hb_codepoint_t b) { if (unlikely (!successful)) return true; /* https://github.com/harfbuzz/harfbuzz/issues/657 */ diff --git a/src/hb-set.hh b/src/hb-set.hh index 7a61de7c8..7d1c941e4 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -84,8 +84,6 @@ struct hb_sparseset_t uint32_t hash () const { return s.hash (); } void add (hb_codepoint_t g) { s.add (g); } - bool test_and_add (hb_codepoint_t g) { return s.test_and_add (g); } - bool test_and_del (hb_codepoint_t g) { return s.test_and_del (g); } bool add_range (hb_codepoint_t a, hb_codepoint_t b) { return s.add_range (a, b); } template