mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-21 23:11:04 +01:00
[vector] Add copy-constructor for array_t's
This commit is contained in:
1 parent
42aba5ff30
commit
5872bdf64d
3 files changed
+23
-6
No files matched your search
@@ -381,7 +381,7 @@ struct Glyph
|
||||
if (points_with_deltas != nullptr && depth == 0 && type == COMPOSITE)
|
||||
{
|
||||
if (unlikely (!points_with_deltas->resize (points.length))) return false;
|
||||
points_with_deltas->copy_vector (points);
|
||||
*points_with_deltas = points;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
|
||||
+17
-5
@@ -62,7 +62,19 @@ struct hb_vector_t
|
||||
{
|
||||
alloc (o.length, true);
|
||||
if (unlikely (in_error ())) return;
|
||||
copy_vector (o);
|
||||
copy_array (o.as_array ());
|
||||
}
|
||||
hb_vector_t (array_t o) : hb_vector_t ()
|
||||
{
|
||||
alloc (o.length, true);
|
||||
if (unlikely (in_error ())) return;
|
||||
copy_array (o);
|
||||
}
|
||||
hb_vector_t (c_array_t o) : hb_vector_t ()
|
||||
{
|
||||
alloc (o.length, true);
|
||||
if (unlikely (in_error ())) return;
|
||||
copy_array (o);
|
||||
}
|
||||
hb_vector_t (hb_vector_t &&o)
|
||||
{
|
||||
@@ -119,7 +131,7 @@ struct hb_vector_t
|
||||
alloc (o.length, true);
|
||||
if (unlikely (in_error ())) return *this;
|
||||
|
||||
copy_vector (o);
|
||||
copy_array (o.as_array ());
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -287,7 +299,7 @@ struct hb_vector_t
|
||||
template <typename T = Type,
|
||||
hb_enable_if (hb_is_trivially_copyable (T))>
|
||||
void
|
||||
copy_vector (const hb_vector_t &other)
|
||||
copy_array (hb_array_t<const Type> other)
|
||||
{
|
||||
length = other.length;
|
||||
if (!HB_OPTIMIZE_SIZE_VAL && sizeof (T) >= sizeof (long long))
|
||||
@@ -301,7 +313,7 @@ struct hb_vector_t
|
||||
hb_enable_if (!hb_is_trivially_copyable (T) &&
|
||||
std::is_copy_constructible<T>::value)>
|
||||
void
|
||||
copy_vector (const hb_vector_t &other)
|
||||
copy_array (hb_array_t<const Type> other)
|
||||
{
|
||||
length = 0;
|
||||
while (length < other.length)
|
||||
@@ -316,7 +328,7 @@ struct hb_vector_t
|
||||
std::is_default_constructible<T>::value &&
|
||||
std::is_copy_assignable<T>::value)>
|
||||
void
|
||||
copy_vector (const hb_vector_t &other)
|
||||
copy_array (hb_array_t<const Type> other)
|
||||
{
|
||||
length = 0;
|
||||
while (length < other.length)
|
||||
|
||||
@@ -176,6 +176,11 @@ main (int argc, char **argv)
|
||||
assert (s.get_population () == 0);
|
||||
}
|
||||
|
||||
{
|
||||
hb_vector_t<hb_map_t> v;
|
||||
hb_map_t m;
|
||||
v.push (m);
|
||||
}
|
||||
{
|
||||
hb_vector_t<hb_map_t> v;
|
||||
hb_map_t m;
|
||||
|
||||
Reference in new issue
Block a user