mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-25 08:51:07 +01:00
[vector] Introduce realloc_moves tag
Some types (even aggregate) can be moved using realloc(). Extend the fast path to hb_hashmap and tuple_delta_t.
This commit is contained in:
1 parent
7b46d772c4
commit
29d49eced8
4 files changed
+10
-3
No files matched your search
@@ -47,6 +47,8 @@ enum hb_not_found_t
|
||||
template <typename Type>
|
||||
struct hb_array_t : hb_iter_with_fallback_t<hb_array_t<Type>, Type&>
|
||||
{
|
||||
static constexpr bool realloc_move = true;
|
||||
|
||||
/*
|
||||
* Constructors.
|
||||
*/
|
||||
|
||||
@@ -42,6 +42,8 @@ template <typename K, typename V,
|
||||
bool minus_one = false>
|
||||
struct hb_hashmap_t
|
||||
{
|
||||
static constexpr bool realloc_move = true;
|
||||
|
||||
hb_hashmap_t () { init (); }
|
||||
~hb_hashmap_t () { fini (); }
|
||||
|
||||
|
||||
@@ -434,6 +434,8 @@ enum packed_delta_flag_t
|
||||
|
||||
struct tuple_delta_t
|
||||
{
|
||||
static constexpr bool realloc_move = true; // Watch out when adding new members!
|
||||
|
||||
public:
|
||||
hb_hashmap_t<hb_tag_t, Triple> axis_tuples;
|
||||
|
||||
|
||||
+4
-3
@@ -37,6 +37,8 @@ template <typename Type,
|
||||
bool sorted=false>
|
||||
struct hb_vector_t
|
||||
{
|
||||
static constexpr bool realloc_move = true;
|
||||
|
||||
typedef Type item_t;
|
||||
static constexpr unsigned item_size = hb_static_size (Type);
|
||||
using array_t = typename std::conditional<sorted, hb_sorted_array_t<Type>, hb_array_t<Type>>::type;
|
||||
@@ -268,10 +270,9 @@ struct hb_vector_t
|
||||
}
|
||||
return new_array;
|
||||
}
|
||||
/* Specialization for hb_vector_t<hb_{vector,array}_t<U>> to speed up. */
|
||||
/* Specialization for types that can be moved using realloc(). */
|
||||
template <typename T = Type,
|
||||
hb_enable_if (hb_is_same (T, hb_vector_t<typename T::item_t>) ||
|
||||
hb_is_same (T, hb_array_t <typename T::item_t>))>
|
||||
hb_enable_if (T::realloc_move)>
|
||||
Type *
|
||||
realloc_vector (unsigned new_allocated, hb_priority<1>)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user