Micro optimization
This commit is contained in:
parent
164c13d73f
commit
7cd33f2304
|
@ -105,34 +105,36 @@ _hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
|
|||
* shaper which many people unfortunately still request.
|
||||
*/
|
||||
|
||||
bool has_space;
|
||||
hb_codepoint_t space;
|
||||
has_space = font->get_glyph (' ', 0, &space);
|
||||
bool has_space = font->get_glyph (' ', 0, &space);
|
||||
|
||||
buffer->clear_positions ();
|
||||
|
||||
hb_direction_t direction = buffer->props.direction;
|
||||
hb_unicode_funcs_t *unicode = buffer->unicode;
|
||||
unsigned int count = buffer->len;
|
||||
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
hb_glyph_position_t *pos = buffer->pos;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
if (has_space && buffer->unicode->is_default_ignorable (buffer->info[i].codepoint)) {
|
||||
buffer->info[i].codepoint = space;
|
||||
buffer->pos[i].x_advance = 0;
|
||||
buffer->pos[i].y_advance = 0;
|
||||
if (has_space && unicode->is_default_ignorable (info[i].codepoint)) {
|
||||
info[i].codepoint = space;
|
||||
pos[i].x_advance = 0;
|
||||
pos[i].y_advance = 0;
|
||||
continue;
|
||||
}
|
||||
font->get_glyph (buffer->info[i].codepoint, 0, &buffer->info[i].codepoint);
|
||||
font->get_glyph_advance_for_direction (buffer->info[i].codepoint,
|
||||
buffer->props.direction,
|
||||
&buffer->pos[i].x_advance,
|
||||
&buffer->pos[i].y_advance);
|
||||
font->subtract_glyph_origin_for_direction (buffer->info[i].codepoint,
|
||||
buffer->props.direction,
|
||||
&buffer->pos[i].x_offset,
|
||||
&buffer->pos[i].y_offset);
|
||||
font->get_glyph (info[i].codepoint, 0, &info[i].codepoint);
|
||||
font->get_glyph_advance_for_direction (info[i].codepoint,
|
||||
direction,
|
||||
&pos[i].x_advance,
|
||||
&pos[i].y_advance);
|
||||
font->subtract_glyph_origin_for_direction (info[i].codepoint,
|
||||
direction,
|
||||
&pos[i].x_offset,
|
||||
&pos[i].y_offset);
|
||||
}
|
||||
|
||||
if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction))
|
||||
if (HB_DIRECTION_IS_BACKWARD (direction))
|
||||
hb_buffer_reverse (buffer);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -223,6 +223,7 @@ static void
|
|||
arabic_joining (hb_buffer_t *buffer)
|
||||
{
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
unsigned int prev = (unsigned int) -1, state = 0;
|
||||
|
||||
/* Check pre-context */
|
||||
|
@ -241,19 +242,19 @@ arabic_joining (hb_buffer_t *buffer)
|
|||
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
unsigned int this_type = get_joining_type (buffer->info[i].codepoint, _hb_glyph_info_get_general_category (&buffer->info[i]));
|
||||
unsigned int this_type = get_joining_type (info[i].codepoint, _hb_glyph_info_get_general_category (&info[i]));
|
||||
|
||||
if (unlikely (this_type == JOINING_TYPE_T)) {
|
||||
buffer->info[i].arabic_shaping_action() = NONE;
|
||||
info[i].arabic_shaping_action() = NONE;
|
||||
continue;
|
||||
}
|
||||
|
||||
const arabic_state_table_entry *entry = &arabic_state_table[state][this_type];
|
||||
|
||||
if (entry->prev_action != NONE && prev != (unsigned int) -1)
|
||||
buffer->info[prev].arabic_shaping_action() = entry->prev_action;
|
||||
info[prev].arabic_shaping_action() = entry->prev_action;
|
||||
|
||||
buffer->info[i].arabic_shaping_action() = entry->curr_action;
|
||||
info[i].arabic_shaping_action() = entry->curr_action;
|
||||
|
||||
prev = i;
|
||||
state = entry->next_state;
|
||||
|
@ -269,7 +270,7 @@ arabic_joining (hb_buffer_t *buffer)
|
|||
|
||||
const arabic_state_table_entry *entry = &arabic_state_table[state][this_type];
|
||||
if (entry->prev_action != NONE && prev != (unsigned int) -1)
|
||||
buffer->info[prev].arabic_shaping_action() = entry->prev_action;
|
||||
info[prev].arabic_shaping_action() = entry->prev_action;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -299,8 +300,9 @@ setup_masks_arabic (const hb_ot_shape_plan_t *plan,
|
|||
mongolian_variation_selectors (buffer);
|
||||
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
buffer->info[i].mask |= arabic_plan->mask_array[buffer->info[i].arabic_shaping_action()];
|
||||
info[i].mask |= arabic_plan->mask_array[info[i].arabic_shaping_action()];
|
||||
|
||||
HB_BUFFER_DEALLOCATE_VAR (buffer, arabic_shaping_action);
|
||||
}
|
||||
|
@ -312,9 +314,10 @@ nuke_joiners (const hb_ot_shape_plan_t *plan HB_UNUSED,
|
|||
hb_buffer_t *buffer)
|
||||
{
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
if (_hb_glyph_info_is_zwj (&buffer->info[i]))
|
||||
_hb_glyph_info_flip_joiners (&buffer->info[i]);
|
||||
if (_hb_glyph_info_is_zwj (&info[i]))
|
||||
_hb_glyph_info_flip_joiners (&info[i]);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -635,8 +635,9 @@ setup_masks_indic (const hb_ot_shape_plan_t *plan HB_UNUSED,
|
|||
* and setup masks later on in a pause-callback. */
|
||||
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
set_indic_properties (buffer->info[i]);
|
||||
set_indic_properties (info[i]);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -673,10 +674,12 @@ update_consonant_positions (const hb_ot_shape_plan_t *plan,
|
|||
{
|
||||
hb_face_t *face = font->face;
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
if (buffer->info[i].indic_position() == POS_BASE_C) {
|
||||
hb_codepoint_t consonant = buffer->info[i].codepoint;
|
||||
buffer->info[i].indic_position() = consonant_position_from_face (indic_plan, consonant, virama, face);
|
||||
if (info[i].indic_position() == POS_BASE_C)
|
||||
{
|
||||
hb_codepoint_t consonant = info[i].codepoint;
|
||||
info[i].indic_position() = consonant_position_from_face (indic_plan, consonant, virama, face);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1228,8 +1231,10 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
|
|||
/* Note: This loop is extra overhead, but should not be measurable. */
|
||||
bool has_broken_syllables = false;
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
if ((buffer->info[i].syllable() & 0x0F) == broken_cluster) {
|
||||
if ((info[i].syllable() & 0x0F) == broken_cluster)
|
||||
{
|
||||
has_broken_syllables = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -277,8 +277,9 @@ setup_masks_myanmar (const hb_ot_shape_plan_t *plan HB_UNUSED,
|
|||
* and setup masks later on in a pause-callback. */
|
||||
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
set_myanmar_properties (buffer->info[i]);
|
||||
set_myanmar_properties (info[i]);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -451,8 +452,10 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
|
|||
/* Note: This loop is extra overhead, but should not be measurable. */
|
||||
bool has_broken_syllables = false;
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
if ((buffer->info[i].syllable() & 0x0F) == broken_cluster) {
|
||||
if ((info[i].syllable() & 0x0F) == broken_cluster)
|
||||
{
|
||||
has_broken_syllables = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -174,8 +174,9 @@ setup_masks_sea (const hb_ot_shape_plan_t *plan HB_UNUSED,
|
|||
* and setup masks later on in a pause-callback. */
|
||||
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
set_sea_properties (buffer->info[i]);
|
||||
set_sea_properties (info[i]);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -278,8 +279,10 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
|
|||
/* Note: This loop is extra overhead, but should not be measurable. */
|
||||
bool has_broken_syllables = false;
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
if ((buffer->info[i].syllable() & 0x0F) == broken_cluster) {
|
||||
if ((info[i].syllable() & 0x0F) == broken_cluster)
|
||||
{
|
||||
has_broken_syllables = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -167,11 +167,12 @@ _hb_ot_shape_fallback_position_recategorize_marks (const hb_ot_shape_plan_t *pla
|
|||
hb_buffer_t *buffer)
|
||||
{
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
if (_hb_glyph_info_get_general_category (&buffer->info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) {
|
||||
unsigned int combining_class = _hb_glyph_info_get_modified_combining_class (&buffer->info[i]);
|
||||
combining_class = recategorize_combining_class (buffer->info[i].codepoint, combining_class);
|
||||
_hb_glyph_info_set_modified_combining_class (&buffer->info[i], combining_class);
|
||||
if (_hb_glyph_info_get_general_category (&info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) {
|
||||
unsigned int combining_class = _hb_glyph_info_get_modified_combining_class (&info[i]);
|
||||
combining_class = recategorize_combining_class (info[i].codepoint, combining_class);
|
||||
_hb_glyph_info_set_modified_combining_class (&info[i], combining_class);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,8 +182,9 @@ zero_mark_advances (hb_buffer_t *buffer,
|
|||
unsigned int start,
|
||||
unsigned int end)
|
||||
{
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = start; i < end; i++)
|
||||
if (_hb_glyph_info_get_general_category (&buffer->info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
|
||||
if (_hb_glyph_info_get_general_category (&info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
|
||||
{
|
||||
buffer->pos[i].x_advance = 0;
|
||||
buffer->pos[i].y_advance = 0;
|
||||
|
@ -327,12 +329,13 @@ position_around_base (const hb_ot_shape_plan_t *plan,
|
|||
unsigned int last_lig_component = (unsigned int) -1;
|
||||
unsigned int last_combining_class = 255;
|
||||
hb_glyph_extents_t cluster_extents = base_extents; /* Initialization is just to shut gcc up. */
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = base + 1; i < end; i++)
|
||||
if (_hb_glyph_info_get_modified_combining_class (&buffer->info[i]))
|
||||
if (_hb_glyph_info_get_modified_combining_class (&info[i]))
|
||||
{
|
||||
if (num_lig_components > 1) {
|
||||
unsigned int this_lig_id = _hb_glyph_info_get_lig_id (&buffer->info[i]);
|
||||
unsigned int this_lig_component = _hb_glyph_info_get_lig_comp (&buffer->info[i]) - 1;
|
||||
unsigned int this_lig_id = _hb_glyph_info_get_lig_id (&info[i]);
|
||||
unsigned int this_lig_component = _hb_glyph_info_get_lig_comp (&info[i]) - 1;
|
||||
/* Conditions for attaching to the last component. */
|
||||
if (!lig_id || lig_id != this_lig_id || this_lig_component >= num_lig_components)
|
||||
this_lig_component = num_lig_components - 1;
|
||||
|
@ -355,7 +358,7 @@ position_around_base (const hb_ot_shape_plan_t *plan,
|
|||
}
|
||||
}
|
||||
|
||||
unsigned int this_combining_class = _hb_glyph_info_get_modified_combining_class (&buffer->info[i]);
|
||||
unsigned int this_combining_class = _hb_glyph_info_get_modified_combining_class (&info[i]);
|
||||
if (last_combining_class != this_combining_class)
|
||||
{
|
||||
last_combining_class = this_combining_class;
|
||||
|
@ -391,13 +394,14 @@ position_cluster (const hb_ot_shape_plan_t *plan,
|
|||
return;
|
||||
|
||||
/* Find the base glyph */
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = start; i < end; i++)
|
||||
if (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&buffer->info[i])))
|
||||
if (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&info[i])))
|
||||
{
|
||||
/* Find mark glyphs */
|
||||
unsigned int j;
|
||||
for (j = i + 1; j < end; j++)
|
||||
if (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&buffer->info[j])))
|
||||
if (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&info[j])))
|
||||
break;
|
||||
|
||||
position_around_base (plan, font, buffer, i, j);
|
||||
|
@ -432,15 +436,13 @@ _hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan,
|
|||
{
|
||||
if (!plan->has_kern) return;
|
||||
|
||||
unsigned int count = buffer->len;
|
||||
|
||||
OT::hb_apply_context_t c (1, font, buffer);
|
||||
c.set_lookup_mask (plan->kern_mask);
|
||||
c.set_lookup_props (OT::LookupFlag::IgnoreMarks);
|
||||
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
hb_glyph_position_t *pos = buffer->pos;
|
||||
|
||||
for (unsigned int idx = 0; idx < count;)
|
||||
{
|
||||
OT::hb_apply_context_t::skipping_forward_iterator_t skippy_iter (&c, idx, 1);
|
||||
|
|
|
@ -227,8 +227,9 @@ static void
|
|||
hb_set_unicode_props (hb_buffer_t *buffer)
|
||||
{
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
_hb_glyph_info_set_unicode_props (&buffer->info[i], buffer->unicode);
|
||||
_hb_glyph_info_set_unicode_props (&info[i], buffer->unicode);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -263,8 +264,9 @@ static void
|
|||
hb_form_clusters (hb_buffer_t *buffer)
|
||||
{
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 1; i < count; i++)
|
||||
if (HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&buffer->info[i])))
|
||||
if (HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&info[i])))
|
||||
buffer->merge_clusters (i - 1, i + 1);
|
||||
}
|
||||
|
||||
|
@ -382,8 +384,9 @@ hb_ot_map_glyphs_fast (hb_buffer_t *buffer)
|
|||
{
|
||||
/* Normalization process sets up glyph_index(), we just copy it. */
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
buffer->info[i].codepoint = buffer->info[i].glyph_index();
|
||||
info[i].codepoint = info[i].glyph_index();
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -483,8 +486,9 @@ static inline void
|
|||
zero_mark_widths_by_unicode (hb_buffer_t *buffer, bool adjust_offsets)
|
||||
{
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
if (_hb_glyph_info_get_general_category (&buffer->info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
|
||||
if (_hb_glyph_info_get_general_category (&info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
|
||||
{
|
||||
if (adjust_offsets)
|
||||
adjust_mark_offsets (&buffer->pos[i]);
|
||||
|
@ -496,8 +500,9 @@ static inline void
|
|||
zero_mark_widths_by_gdef (hb_buffer_t *buffer, bool adjust_offsets)
|
||||
{
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
if (_hb_glyph_info_is_mark (&buffer->info[i]))
|
||||
if (_hb_glyph_info_is_mark (&info[i]))
|
||||
{
|
||||
if (adjust_offsets)
|
||||
adjust_mark_offsets (&buffer->pos[i]);
|
||||
|
@ -773,8 +778,9 @@ hb_ot_shape_glyphs_closure (hb_font_t *font,
|
|||
bool mirror = hb_script_get_horizontal_direction (buffer->props.script) == HB_DIRECTION_RTL;
|
||||
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
add_char (font, buffer->unicode, mirror, buffer->info[i].codepoint, glyphs);
|
||||
add_char (font, buffer->unicode, mirror, info[i].codepoint, glyphs);
|
||||
|
||||
hb_set_t lookups;
|
||||
lookups.init ();
|
||||
|
|
Loading…
Reference in New Issue