提交 2a2e28e7 编写于 作者: B Behdad Esfahbod

Don't keep instance in hb_table_lazy_loader_t

上级 57bac8f6
...@@ -1239,7 +1239,6 @@ struct hb_table_lazy_loader_t ...@@ -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 ...@@ -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 ...@@ -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;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册