[HarfBuzz] harfbuzz: Branch 'master' - 3 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Sat Jun 2 00:48:59 UTC 2018
src/hb-coretext.cc | 20 +++-----------------
src/hb-ot-cmap-table.hh | 3 ++-
src/hb-ot-layout.cc | 3 +--
src/hb-ot-map.cc | 17 ++++-------------
src/hb-ot-post-table.hh | 6 +-----
src/hb-private.hh | 31 +++++++++++++++++++------------
src/hb-subset-plan.cc | 2 --
src/hb-subset.cc | 2 --
src/hb-uniscribe.cc | 28 ++++++++--------------------
9 files changed, 38 insertions(+), 74 deletions(-)
New commits:
commit f7515769fd024faca888a47c58f87fb868b0e760
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Jun 1 17:48:37 2018 -0700
[vector] Use Crap pool in push() as well
diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index 84cc22fd..61f9c35a 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -670,15 +670,11 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
feature_event_t *event;
event = feature_events.push ();
- if (unlikely (!event))
- goto fail_features;
event->index = features[i].start;
event->start = true;
event->feature = feature;
event = feature_events.push ();
- if (unlikely (!event))
- goto fail_features;
event->index = features[i].end;
event->start = false;
event->feature = feature;
@@ -692,8 +688,6 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
feature.order = num_features + 1;
feature_event_t *event = feature_events.push ();
- if (unlikely (!event))
- goto fail_features;
event->index = 0; /* This value does magic. */
event->start = false;
event->feature = feature;
@@ -710,8 +704,6 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
{
/* Save a snapshot of active features and the range. */
range_record_t *range = range_records.push ();
- if (unlikely (!range))
- goto fail_features;
if (active_features.len)
{
@@ -769,10 +761,9 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
last_index = event->index;
}
- if (event->start) {
- active_feature_t *feature = active_features.push (event->feature);
- if (unlikely (!feature))
- goto fail_features;
+ if (event->start)
+ {
+ active_features.push (event->feature);
} else {
active_feature_t *feature = active_features.find (&event->feature);
if (feature)
@@ -780,11 +771,6 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
}
}
}
- else
- {
- fail_features:
- num_features = 0;
- }
unsigned int scratch_size;
hb_buffer_t::scratch_buffer_t *scratch = buffer->get_scratch_buffer (&scratch_size);
diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index 731aa410..c1903f6e 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -211,7 +211,8 @@ struct CmapSubtableFormat4
}
// There must be a final entry with end_code == 0xFFFF. Check if we need to add one.
- if (segment == nullptr || segment->end_code != 0xFFFF) {
+ if (segment == nullptr || segment->end_code != 0xFFFF)
+ {
segment = segments->push ();
segment->start_code.set (0xFFFF);
segment->end_code.set (0xFFFF);
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index adb00536..8d1471a3 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -1099,8 +1099,7 @@ struct hb_get_subtables_context_t :
inline return_t dispatch (const T &obj)
{
hb_applicable_t *entry = array.push();
- if (likely (entry))
- entry->init (&obj, apply_to<T>);
+ entry->init (&obj, apply_to<T>);
return HB_VOID;
}
static return_t default_return_value (void) { return HB_VOID; }
diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc
index b7cbafaa..504f0945 100644
--- a/src/hb-ot-map.cc
+++ b/src/hb-ot-map.cc
@@ -67,7 +67,6 @@ void hb_ot_map_builder_t::add_feature (hb_tag_t tag, unsigned int value,
hb_ot_map_feature_flags_t flags)
{
feature_info_t *info = feature_infos.push();
- if (unlikely (!info)) return;
if (unlikely (!tag)) return;
info->tag = tag;
info->seq = feature_infos.len;
@@ -108,8 +107,6 @@ hb_ot_map_builder_t::add_lookups (hb_ot_map_t &m,
if (lookup_indices[i] >= table_lookup_count)
continue;
hb_ot_map_t::lookup_map_t *lookup = m.lookups[table_index].push ();
- if (unlikely (!lookup))
- return;
lookup->mask = mask;
lookup->index = lookup_indices[i];
lookup->auto_zwnj = auto_zwnj;
@@ -124,10 +121,8 @@ hb_ot_map_builder_t::add_lookups (hb_ot_map_t &m,
void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func)
{
stage_info_t *s = stages[table_index].push ();
- if (likely (s)) {
- s->index = current_stage[table_index];
- s->pause_func = pause_func;
- }
+ s->index = current_stage[table_index];
+ s->pause_func = pause_func;
current_stage[table_index]++;
}
@@ -238,8 +233,6 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m,
hb_ot_map_t::feature_map_t *map = m.features.push ();
- if (unlikely (!map))
- break;
map->tag = info->tag;
map->index[0] = feature_index[0];
@@ -321,10 +314,8 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m,
if (stage_index < stages[table_index].len && stages[table_index][stage_index].index == stage) {
hb_ot_map_t::stage_map_t *stage_map = m.stages[table_index].push ();
- if (likely (stage_map)) {
- stage_map->last_lookup = last_num_lookups;
- stage_map->pause_func = stages[table_index][stage_index].pause_func;
- }
+ stage_map->last_lookup = last_num_lookups;
+ stage_map->pause_func = stages[table_index][stage_index].pause_func;
stage_index++;
}
diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index 2762eb59..ab3c0535 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -125,11 +125,7 @@ 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 (data - pool);
- if (unlikely (!offset))
- break;
- }
+ index_to_offset.push (data - pool);
}
inline void fini (void)
{
diff --git a/src/hb-private.hh b/src/hb-private.hh
index 6fee049d..cdb6c306 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -658,17 +658,14 @@ struct hb_vector_t
inline Type *push (void)
{
if (unlikely (!resize (len + 1)))
- return nullptr;
-
+ return &Crap(Type);
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];
+ Type *p = push ();
+ *p = v;
+ return p;
}
/* Allocate for size but don't adjust len. */
diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc
index 97ff14cf..7100efc8 100644
--- a/src/hb-subset-plan.cc
+++ b/src/hb-subset-plan.cc
@@ -97,9 +97,7 @@ _populate_gids_to_retain (hb_face_t *face,
glyphs->alloc (all_gids_to_retain->get_population ());
gid = HB_SET_VALUE_INVALID;
while (all_gids_to_retain->next (&gid))
- {
glyphs->push (gid);
- }
hb_set_destroy (all_gids_to_retain);
glyf.fini ();
diff --git a/src/hb-subset.cc b/src/hb-subset.cc
index d631fc7c..4d2dc293 100644
--- a/src/hb-subset.cc
+++ b/src/hb-subset.cc
@@ -224,8 +224,6 @@ hb_subset_face_add_table (hb_face_t *face, hb_tag_t tag, hb_blob_t *blob)
hb_subset_face_data_t *data = (hb_subset_face_data_t *) face->user_data;
hb_subset_face_data_t::table_entry_t *entry = data->tables.push ();
- if (unlikely (!entry))
- return false;
entry->tag = tag;
entry->blob = hb_blob_reference (blob);
diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc
index 3b52ad3f..6d6afe80 100644
--- a/src/hb-uniscribe.cc
+++ b/src/hb-uniscribe.cc
@@ -646,15 +646,11 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
feature_event_t *event;
event = feature_events.push ();
- if (unlikely (!event))
- goto fail_features;
event->index = features[i].start;
event->start = true;
event->feature = feature;
event = feature_events.push ();
- if (unlikely (!event))
- goto fail_features;
event->index = features[i].end;
event->start = false;
event->feature = feature;
@@ -668,8 +664,6 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
feature.order = num_features + 1;
feature_event_t *event = feature_events.push ();
- if (unlikely (!event))
- goto fail_features;
event->index = 0; /* This value does magic. */
event->start = false;
event->feature = feature;
@@ -686,8 +680,6 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
{
/* Save a snapshot of active features and the range. */
range_record_t *range = range_records.push ();
- if (unlikely (!range))
- goto fail_features;
unsigned int offset = feature_records.len;
@@ -696,8 +688,7 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
{
if (!j || active_features[j].rec.tagFeature != feature_records[feature_records.len - 1].tagFeature)
{
- if (unlikely (!feature_records.push (active_features[j].rec)))
- goto fail_features;
+ feature_records.push (active_features[j].rec);
}
else
{
@@ -716,10 +707,12 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
last_index = event->index;
}
- if (event->start) {
- if (unlikely (!active_features.push (event->feature)))
- goto fail_features;
- } else {
+ if (event->start)
+ {
+ active_features.push (event->feature);
+ }
+ else
+ {
active_feature_t *feature = active_features.find (&event->feature);
if (feature)
active_features.remove (feature - active_features.arrayZ);
@@ -727,7 +720,7 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
}
if (!range_records.len) /* No active feature found. */
- goto fail_features;
+ num_features = 0;
/* Fixup the pointers. */
for (unsigned int i = 0; i < range_records.len; i++)
@@ -736,11 +729,6 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
range->props.potfRecords = feature_records.arrayZ + reinterpret_cast<uintptr_t> (range->props.potfRecords);
}
}
- else
- {
- fail_features:
- num_features = 0;
- }
#define FAIL(...) \
HB_STMT_START { \
commit 975bdd5ef562e37655067b703b2b9ca7481f4985
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Jun 1 17:37:13 2018 -0700
[vector] Keep success status
diff --git a/src/hb-private.hh b/src/hb-private.hh
index e626a141..6fee049d 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -625,11 +625,12 @@ struct CrapOrNull<const Type> {
#define HB_PREALLOCED_ARRAY_INIT {0, 0, nullptr}
-template <typename Type, unsigned int StaticSize=16>
+template <typename Type, unsigned int StaticSize=8>
struct hb_vector_t
{
unsigned int len;
unsigned int allocated;
+ bool successful;
Type *arrayZ;
Type static_array[StaticSize];
@@ -637,6 +638,7 @@ struct hb_vector_t
{
len = 0;
allocated = ARRAY_LENGTH (static_array);
+ successful = true;
arrayZ = static_array;
}
@@ -672,6 +674,9 @@ struct hb_vector_t
/* Allocate for size but don't adjust len. */
inline bool alloc (unsigned int size)
{
+ if (unlikely (!successful))
+ return false;
+
if (likely (size <= allocated))
return true;
@@ -697,7 +702,10 @@ struct hb_vector_t
}
if (unlikely (!new_array))
+ {
+ successful = false;
return false;
+ }
arrayZ = new_array;
allocated = new_allocated;
commit 1ab3c3ed1bbc404086aefffaef4b8261bb77caa7
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Jun 1 17:34:24 2018 -0700
[vector] Whitespace
diff --git a/src/hb-private.hh b/src/hb-private.hh
index b4633213..e626a141 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -683,15 +683,17 @@ struct hb_vector_t
Type *new_array = nullptr;
- if (arrayZ == static_array) {
+ if (arrayZ == static_array)
+ {
new_array = (Type *) calloc (new_allocated, sizeof (Type));
if (new_array)
memcpy (new_array, arrayZ, len * sizeof (Type));
- } else {
+ }
+ else
+ {
bool overflows = (new_allocated < allocated) || _hb_unsigned_int_mul_overflows (new_allocated, sizeof (Type));
- if (likely (!overflows)) {
+ if (likely (!overflows))
new_array = (Type *) realloc (arrayZ, new_allocated * sizeof (Type));
- }
}
if (unlikely (!new_array))
More information about the HarfBuzz
mailing list