提交 abfbba19 编写于 作者: B Behdad Esfahbod

Add hb_array<>()

Simplifies transient object creation.

Fixes https://github.com/harfbuzz/harfbuzz/issues/1301
上级 17ffbc07
......@@ -55,7 +55,7 @@ struct TrackTableEntry
unsigned int index,
unsigned int nSizes) const
{
return hb_array_t<const FWORD> ((base+valuesZ).arrayZ, nSizes)[index];
return hb_array ((base+valuesZ).arrayZ, nSizes)[index];
}
public:
......
......@@ -537,6 +537,8 @@ struct hb_array_t
T *arrayZ;
unsigned int len;
};
template <typename T>
hb_array_t<T> hb_array (T *array, unsigned int len) { return hb_array_t<T> (array, len); }
struct hb_bytes_t
{
......
......@@ -330,8 +330,7 @@ struct ResourceTypeRecord
inline const ResourceRecord& get_resource_record (unsigned int i,
const void *type_base) const
{
return hb_array_t<const ResourceRecord> ((type_base+resourcesZ).arrayZ,
get_resource_count ()) [i];
return hb_array ((type_base+resourcesZ).arrayZ, get_resource_count ())[i];
}
inline bool sanitize (hb_sanitize_context_t *c,
......
......@@ -55,7 +55,7 @@ struct CPALV1Tail
{
if (!paletteFlagsZ) return HB_OT_COLOR_PALETTE_FLAG_DEFAULT;
return (hb_ot_color_palette_flags_t) (uint32_t)
hb_array_t<const HBUINT32> ((base+paletteFlagsZ).arrayZ, palette_count)[palette_index];
hb_array ((base+paletteFlagsZ).arrayZ, palette_count)[palette_index];
}
inline unsigned int
......@@ -64,7 +64,7 @@ struct CPALV1Tail
unsigned int palette_count) const
{
if (!paletteLabelsZ) return HB_NAME_ID_INVALID;
return hb_array_t<const NameID> ((base+paletteLabelsZ).arrayZ, palette_count)[palette_index];
return hb_array ((base+paletteLabelsZ).arrayZ, palette_count)[palette_index];
}
inline unsigned int
......@@ -73,7 +73,7 @@ struct CPALV1Tail
unsigned int color_count) const
{
if (!colorLabelsZ) return HB_NAME_ID_INVALID;
return hb_array_t<const NameID> ((base+colorLabelsZ).arrayZ, color_count)[color_index];
return hb_array ((base+colorLabelsZ).arrayZ, color_count)[color_index];
}
public:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册