Don't keep instance in hb_table_lazy_loader_t
This commit is contained in:
parent
57bac8f699
commit
2a2e28e701
|
@ -1239,7 +1239,6 @@ struct hb_table_lazy_loader_t
|
||||||
{
|
{
|
||||||
face = face_;
|
face = face_;
|
||||||
blob = nullptr;
|
blob = nullptr;
|
||||||
instance = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void fini (void)
|
inline void fini (void)
|
||||||
|
@ -1250,19 +1249,18 @@ struct hb_table_lazy_loader_t
|
||||||
inline const T* get (void) const
|
inline const T* get (void) const
|
||||||
{
|
{
|
||||||
retry:
|
retry:
|
||||||
T *p = (T *) hb_atomic_ptr_get (&instance);
|
hb_blob_t *blob_ = (hb_blob_t *) hb_atomic_ptr_get (&blob);
|
||||||
if (unlikely (!p))
|
if (unlikely (!blob_))
|
||||||
{
|
{
|
||||||
hb_blob_t *blob_ = OT::Sanitizer<T>().sanitize (face->reference_table (T::tableTag));
|
blob_ = OT::Sanitizer<T>().sanitize (face->reference_table (T::tableTag));
|
||||||
p = const_cast<T *>(blob_->as<T> ());
|
if (!hb_atomic_ptr_cmpexch (&blob, nullptr, blob_))
|
||||||
if (!hb_atomic_ptr_cmpexch (const_cast<T **>(&instance), nullptr, p))
|
|
||||||
{
|
{
|
||||||
hb_blob_destroy (blob_);
|
hb_blob_destroy (blob_);
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
blob = blob_;
|
blob = blob_;
|
||||||
}
|
}
|
||||||
return p;
|
return blob_->as<T> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const T* operator-> (void) const
|
inline const T* operator-> (void) const
|
||||||
|
@ -1270,10 +1268,9 @@ struct hb_table_lazy_loader_t
|
||||||
return get();
|
return get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
hb_face_t *face;
|
hb_face_t *face;
|
||||||
mutable hb_blob_t *blob;
|
mutable hb_blob_t *blob;
|
||||||
private:
|
|
||||||
mutable T *instance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue