Add hb_vector_t::push(const Type &v)
Makes for cleaner code.
diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index 3924c8e..84cc22f 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -770,10 +770,9 @@
}
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)
diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index bec508c..9a1edea 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -126,10 +126,9 @@
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)
diff --git a/src/hb-private.hh b/src/hb-private.hh
index 183f2a4..d3381eb 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -551,9 +551,17 @@
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 @@
l.unlock ();
}
} else {
- item = items.push ();
- if (likely (item))
- *item = v;
+ item = items.push (v);
l.unlock ();
}
return item;
@@ -779,9 +785,7 @@
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;
diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc
index d70215b..3e53e84 100644
--- a/src/hb-subset-plan.cc
+++ b/src/hb-subset-plan.cc
@@ -91,10 +91,8 @@
{
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 @@
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 @@
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 ();
diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc
index 3cd419e..3b52ad3 100644
--- a/src/hb-uniscribe.cc
+++ b/src/hb-uniscribe.cc
@@ -696,10 +696,8 @@
{
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 @@
}
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)