Revert "[set] Add test_and_add / test_and_del"

This reverts commit de1237fbf2.

This seems to be a net loss.
pull/4324/head
Behdad Esfahbod 2 years ago
parent 10b776b0c3
commit 867640af31
  1. 17
      src/graph/graph.hh
  2. 25
      src/hb-bit-page.hh
  3. 2
      src/hb-bit-set-invertible.hh
  4. 16
      src/hb-bit-set.hh
  5. 2
      src/hb-set.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];

@ -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);

@ -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); }

@ -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 */

@ -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 <typename T>

Loading…
Cancel
Save