[vector] Add remove_unordered
Saves 5% in NotoNastaliq/1000 subset benchmark.
This commit is contained in:
parent
4b8d8fbee4
commit
915c1a00cf
|
@ -132,7 +132,7 @@ struct graph_t
|
||||||
for (unsigned i = 0; i < parents.length; i++)
|
for (unsigned i = 0; i < parents.length; i++)
|
||||||
{
|
{
|
||||||
if (parents[i] != parent_index) continue;
|
if (parents[i] != parent_index) continue;
|
||||||
parents.remove (i);
|
parents.remove_unordered (i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ struct graph_t
|
||||||
if ((obj.head + link.position) != offset)
|
if ((obj.head + link.position) != offset)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
obj.real_links.remove (i);
|
obj.real_links.remove_unordered (i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ struct AnchorMatrix : public OT::Layout::GPOS_impl::AnchorMatrix
|
||||||
auto& child = c.graph.vertices_[child_idx];
|
auto& child = c.graph.vertices_[child_idx];
|
||||||
child.remove_parent (this_index);
|
child.remove_parent (this_index);
|
||||||
|
|
||||||
o.real_links.remove (i);
|
o.real_links.remove_unordered (i);
|
||||||
num_links--;
|
num_links--;
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|
|
@ -391,7 +391,7 @@ struct hb_vector_t
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove (unsigned int i)
|
void remove_ordered (unsigned int i)
|
||||||
{
|
{
|
||||||
if (unlikely (i >= length))
|
if (unlikely (i >= length))
|
||||||
return;
|
return;
|
||||||
|
@ -400,6 +400,18 @@ struct hb_vector_t
|
||||||
length--;
|
length--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <bool Sorted = sorted,
|
||||||
|
hb_enable_if (!Sorted)>
|
||||||
|
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_)
|
void shrink (int size_)
|
||||||
{
|
{
|
||||||
unsigned int size = size_ < 0 ? 0u : (unsigned int) size_;
|
unsigned int size = size_ < 0 ? 0u : (unsigned int) size_;
|
||||||
|
|
|
@ -162,7 +162,8 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
v2 = v;
|
v2 = v;
|
||||||
|
|
||||||
v2.remove (50);
|
v2.remove_ordered (50);
|
||||||
|
v2.remove_unordered (50);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue