[object] Remove hb_object_is_inert()
This commit is contained in:
parent
2d5ef05d67
commit
9cc4da962f
|
@ -195,6 +195,8 @@ struct hb_object_header_t
|
||||||
hb_reference_count_t ref_count;
|
hb_reference_count_t ref_count;
|
||||||
mutable hb_atomic_int_t writable = 0;
|
mutable hb_atomic_int_t writable = 0;
|
||||||
hb_atomic_ptr_t<hb_user_data_array_t> user_data;
|
hb_atomic_ptr_t<hb_user_data_array_t> user_data;
|
||||||
|
|
||||||
|
bool is_inert () const { return !ref_count.get_relaxed (); }
|
||||||
};
|
};
|
||||||
#define HB_OBJECT_HEADER_STATIC {}
|
#define HB_OBJECT_HEADER_STATIC {}
|
||||||
|
|
||||||
|
@ -232,11 +234,6 @@ static inline void hb_object_init (Type *obj)
|
||||||
obj->header.user_data.init ();
|
obj->header.user_data.init ();
|
||||||
}
|
}
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
static inline bool hb_object_is_inert (const Type *obj)
|
|
||||||
{
|
|
||||||
return unlikely (obj->header.ref_count.is_inert ());
|
|
||||||
}
|
|
||||||
template <typename Type>
|
|
||||||
static inline bool hb_object_is_valid (const Type *obj)
|
static inline bool hb_object_is_valid (const Type *obj)
|
||||||
{
|
{
|
||||||
return likely (obj->header.ref_count.is_valid ());
|
return likely (obj->header.ref_count.is_valid ());
|
||||||
|
@ -255,7 +252,7 @@ template <typename Type>
|
||||||
static inline Type *hb_object_reference (Type *obj)
|
static inline Type *hb_object_reference (Type *obj)
|
||||||
{
|
{
|
||||||
hb_object_trace (obj, HB_FUNC);
|
hb_object_trace (obj, HB_FUNC);
|
||||||
if (unlikely (!obj || hb_object_is_inert (obj)))
|
if (unlikely (!obj || obj->header.is_inert ()))
|
||||||
return obj;
|
return obj;
|
||||||
assert (hb_object_is_valid (obj));
|
assert (hb_object_is_valid (obj));
|
||||||
obj->header.ref_count.inc ();
|
obj->header.ref_count.inc ();
|
||||||
|
@ -265,7 +262,7 @@ template <typename Type>
|
||||||
static inline bool hb_object_destroy (Type *obj)
|
static inline bool hb_object_destroy (Type *obj)
|
||||||
{
|
{
|
||||||
hb_object_trace (obj, HB_FUNC);
|
hb_object_trace (obj, HB_FUNC);
|
||||||
if (unlikely (!obj || hb_object_is_inert (obj)))
|
if (unlikely (!obj || obj->header.is_inert ()))
|
||||||
return false;
|
return false;
|
||||||
assert (hb_object_is_valid (obj));
|
assert (hb_object_is_valid (obj));
|
||||||
if (obj->header.ref_count.dec () != 1)
|
if (obj->header.ref_count.dec () != 1)
|
||||||
|
@ -293,7 +290,7 @@ static inline bool hb_object_set_user_data (Type *obj,
|
||||||
hb_destroy_func_t destroy,
|
hb_destroy_func_t destroy,
|
||||||
hb_bool_t replace)
|
hb_bool_t replace)
|
||||||
{
|
{
|
||||||
if (unlikely (!obj || hb_object_is_inert (obj)))
|
if (unlikely (!obj || obj->header.is_inert ()))
|
||||||
return false;
|
return false;
|
||||||
assert (hb_object_is_valid (obj));
|
assert (hb_object_is_valid (obj));
|
||||||
|
|
||||||
|
@ -320,7 +317,7 @@ template <typename Type>
|
||||||
static inline void *hb_object_get_user_data (Type *obj,
|
static inline void *hb_object_get_user_data (Type *obj,
|
||||||
hb_user_data_key_t *key)
|
hb_user_data_key_t *key)
|
||||||
{
|
{
|
||||||
if (unlikely (!obj || hb_object_is_inert (obj)))
|
if (unlikely (!obj || obj->header.is_inert ()))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
assert (hb_object_is_valid (obj));
|
assert (hb_object_is_valid (obj));
|
||||||
hb_user_data_array_t *user_data = obj->header.user_data.get ();
|
hb_user_data_array_t *user_data = obj->header.user_data.get ();
|
||||||
|
|
Loading…
Reference in New Issue