Add hb_vector_t::push(const Type &v)
Makes for cleaner code.
This commit is contained in:
parent
38ae0add70
commit
65aeabd622
|
@ -770,10 +770,9 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->start) {
|
if (event->start) {
|
||||||
active_feature_t *feature = active_features.push ();
|
active_feature_t *feature = active_features.push (event->feature);
|
||||||
if (unlikely (!feature))
|
if (unlikely (!feature))
|
||||||
goto fail_features;
|
goto fail_features;
|
||||||
*feature = event->feature;
|
|
||||||
} else {
|
} else {
|
||||||
active_feature_t *feature = active_features.find (&event->feature);
|
active_feature_t *feature = active_features.find (&event->feature);
|
||||||
if (feature)
|
if (feature)
|
||||||
|
|
|
@ -126,10 +126,9 @@ struct post
|
||||||
const uint8_t *end = (uint8_t *) table + table_length;
|
const uint8_t *end = (uint8_t *) table + table_length;
|
||||||
for (const uint8_t *data = pool; data < end && data + *data <= end; data += 1 + *data)
|
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))
|
if (unlikely (!offset))
|
||||||
break;
|
break;
|
||||||
*offset = data - pool;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void fini (void)
|
inline void fini (void)
|
||||||
|
|
|
@ -551,9 +551,17 @@ struct hb_vector_t
|
||||||
|
|
||||||
return &arrayZ[len - 1];
|
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. */
|
/* Allocate for size but don't adjust len. */
|
||||||
inline bool alloc(unsigned int size)
|
inline bool alloc (unsigned int size)
|
||||||
{
|
{
|
||||||
if (likely (size <= allocated))
|
if (likely (size <= allocated))
|
||||||
return true;
|
return true;
|
||||||
|
@ -738,9 +746,7 @@ struct hb_lockable_set_t
|
||||||
l.unlock ();
|
l.unlock ();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
item = items.push ();
|
item = items.push (v);
|
||||||
if (likely (item))
|
|
||||||
*item = v;
|
|
||||||
l.unlock ();
|
l.unlock ();
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
|
@ -779,9 +785,7 @@ struct hb_lockable_set_t
|
||||||
l.lock ();
|
l.lock ();
|
||||||
item_t *item = items.find (v);
|
item_t *item = items.find (v);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
item = items.push ();
|
item = items.push (v);
|
||||||
if (likely (item))
|
|
||||||
*item = v;
|
|
||||||
}
|
}
|
||||||
l.unlock ();
|
l.unlock ();
|
||||||
return item;
|
return item;
|
||||||
|
|
|
@ -91,10 +91,8 @@ _populate_codepoints (hb_set_t *input_codepoints,
|
||||||
{
|
{
|
||||||
plan_codepoints.alloc (hb_set_get_population (input_codepoints));
|
plan_codepoints.alloc (hb_set_get_population (input_codepoints));
|
||||||
hb_codepoint_t cp = -1;
|
hb_codepoint_t cp = -1;
|
||||||
while (hb_set_next (input_codepoints, &cp)) {
|
while (hb_set_next (input_codepoints, &cp))
|
||||||
hb_codepoint_t *wr = plan_codepoints.push();
|
plan_codepoints.push(cp);
|
||||||
*wr = cp;
|
|
||||||
}
|
|
||||||
plan_codepoints.qsort (_hb_codepoint_t_cmp);
|
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))
|
if (!cmap.get_nominal_glyph (codepoints[i], &gid))
|
||||||
{
|
{
|
||||||
gid = -1;
|
gid = -1;
|
||||||
*(bad_indices.push ()) = i;
|
bad_indices.push (i);
|
||||||
}
|
}
|
||||||
*(old_gids.push ()) = gid;
|
old_gids.push (gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generally there shouldn't be any */
|
/* 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));
|
old_gids_sorted.alloc (hb_set_get_population (all_gids_to_retain));
|
||||||
hb_codepoint_t gid = HB_SET_VALUE_INVALID;
|
hb_codepoint_t gid = HB_SET_VALUE_INVALID;
|
||||||
while (hb_set_next (all_gids_to_retain, &gid))
|
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);
|
hb_set_destroy (all_gids_to_retain);
|
||||||
glyf.fini ();
|
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)
|
if (!j || active_features[j].rec.tagFeature != feature_records[feature_records.len - 1].tagFeature)
|
||||||
{
|
{
|
||||||
OPENTYPE_FEATURE_RECORD *feature = feature_records.push ();
|
if (unlikely (!feature_records.push (active_features[j].rec)))
|
||||||
if (unlikely (!feature))
|
|
||||||
goto fail_features;
|
goto fail_features;
|
||||||
*feature = active_features[j].rec;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -719,10 +717,8 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->start) {
|
if (event->start) {
|
||||||
active_feature_t *feature = active_features.push ();
|
if (unlikely (!active_features.push (event->feature)))
|
||||||
if (unlikely (!feature))
|
|
||||||
goto fail_features;
|
goto fail_features;
|
||||||
*feature = event->feature;
|
|
||||||
} else {
|
} else {
|
||||||
active_feature_t *feature = active_features.find (&event->feature);
|
active_feature_t *feature = active_features.find (&event->feature);
|
||||||
if (feature)
|
if (feature)
|
||||||
|
|
Loading…
Reference in New Issue