提交 65aeabd6 编写于 作者: B Behdad Esfahbod

Add hb_vector_t::push(const Type &v)

Makes for cleaner code.
上级 38ae0add
......@@ -770,10 +770,9 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
}
if (event->start) {
active_feature_t *feature = active_features.push ();
active_feature_t *feature = active_features.push (event->feature);
if (unlikely (!feature))
goto fail_features;
*feature = event->feature;
} else {
active_feature_t *feature = active_features.find (&event->feature);
if (feature)
......
......@@ -126,10 +126,9 @@ struct post
const uint8_t *end = (uint8_t *) table + table_length;
for (const uint8_t *data = pool; data < end && data + *data <= end; data += 1 + *data)
{
uint32_t *offset = index_to_offset.push ();
uint32_t *offset = index_to_offset.push (data - pool);
if (unlikely (!offset))
break;
*offset = data - pool;
}
}
inline void fini (void)
......
......@@ -551,9 +551,17 @@ struct hb_vector_t
return &arrayZ[len - 1];
}
inline Type *push (const Type& v)
{
if (unlikely (!resize (len + 1)))
return nullptr;
arrayZ[len - 1] = v;
return &arrayZ[len - 1];
}
/* Allocate for size but don't adjust len. */
inline bool alloc(unsigned int size)
inline bool alloc (unsigned int size)
{
if (likely (size <= allocated))
return true;
......@@ -738,9 +746,7 @@ struct hb_lockable_set_t
l.unlock ();
}
} else {
item = items.push ();
if (likely (item))
*item = v;
item = items.push (v);
l.unlock ();
}
return item;
......@@ -779,9 +785,7 @@ struct hb_lockable_set_t
l.lock ();
item_t *item = items.find (v);
if (!item) {
item = items.push ();
if (likely (item))
*item = v;
item = items.push (v);
}
l.unlock ();
return item;
......
......@@ -91,10 +91,8 @@ _populate_codepoints (hb_set_t *input_codepoints,
{
plan_codepoints.alloc (hb_set_get_population (input_codepoints));
hb_codepoint_t cp = -1;
while (hb_set_next (input_codepoints, &cp)) {
hb_codepoint_t *wr = plan_codepoints.push();
*wr = cp;
}
while (hb_set_next (input_codepoints, &cp))
plan_codepoints.push(cp);
plan_codepoints.qsort (_hb_codepoint_t_cmp);
}
......@@ -139,9 +137,9 @@ _populate_gids_to_retain (hb_face_t *face,
if (!cmap.get_nominal_glyph (codepoints[i], &gid))
{
gid = -1;
*(bad_indices.push ()) = i;
bad_indices.push (i);
}
*(old_gids.push ()) = gid;
old_gids.push (gid);
}
/* Generally there shouldn't be any */
......@@ -166,7 +164,7 @@ _populate_gids_to_retain (hb_face_t *face,
old_gids_sorted.alloc (hb_set_get_population (all_gids_to_retain));
hb_codepoint_t gid = HB_SET_VALUE_INVALID;
while (hb_set_next (all_gids_to_retain, &gid))
*(old_gids_sorted.push ()) = gid;
old_gids_sorted.push (gid);
hb_set_destroy (all_gids_to_retain);
glyf.fini ();
......
......@@ -696,10 +696,8 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
{
if (!j || active_features[j].rec.tagFeature != feature_records[feature_records.len - 1].tagFeature)
{
OPENTYPE_FEATURE_RECORD *feature = feature_records.push ();
if (unlikely (!feature))
if (unlikely (!feature_records.push (active_features[j].rec)))
goto fail_features;
*feature = active_features[j].rec;
}
else
{
......@@ -719,10 +717,8 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
}
if (event->start) {
active_feature_t *feature = active_features.push ();
if (unlikely (!feature))
if (unlikely (!active_features.push (event->feature)))
goto fail_features;
*feature = event->feature;
} else {
active_feature_t *feature = active_features.find (&event->feature);
if (feature)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册