From a60b48ef09d4cf77c18fbb0df4c27e82ee89cf9e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 3 Sep 2026 22:30:40 -0600 Subject: [PATCH] OT: Fuse mask initialization into Unicode properties --- src/hb-buffer.hh | 5 ----- src/hb-ot-shape.cc | 18 +++++------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index 770beeee3..1de700170 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -385,11 +385,6 @@ struct hb_buffer_t } /* Advance idx without copying to output. */ void skip_glyph () { idx++; } - void reset_masks (hb_mask_t mask) - { - for (unsigned int j = 0; j < len; j++) - info[j].mask = mask; - } void add_masks (hb_mask_t mask) { for (unsigned int j = 0; j < len; j++) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 691642402..53c774ea7 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -468,7 +468,8 @@ struct hb_ot_shape_context_t /* Prepare */ static void -hb_set_unicode_props (hb_buffer_t *buffer) +hb_set_unicode_props (hb_buffer_t *buffer, + hb_mask_t global_mask) { /* Implement enough of Unicode Graphemes here that shaping * in reverse-direction wouldn't break graphemes. Namely, @@ -482,6 +483,7 @@ hb_set_unicode_props (hb_buffer_t *buffer) hb_glyph_info_t *info = buffer->info; for (unsigned int i = 0; i < count; i++) { + info[i].mask = global_mask; _hb_glyph_info_set_unicode_props (&info[i], buffer); if (info[i].codepoint < 0x80) @@ -519,6 +521,7 @@ hb_set_unicode_props (hb_buffer_t *buffer) _hb_unicode_is_emoji_Extended_Pictographic (info[i + 1].codepoint)) { i++; + info[i].mask = global_mask; _hb_glyph_info_set_unicode_props (&info[i], buffer); _hb_glyph_info_set_continuation (&info[i], buffer); } @@ -743,16 +746,6 @@ hb_ot_shape_setup_masks_fraction (const hb_ot_shape_context_t *c) } } -static inline void -hb_ot_shape_initialize_masks (const hb_ot_shape_context_t *c) -{ - hb_ot_map_t *map = &c->plan->map; - hb_buffer_t *buffer = c->buffer; - - hb_mask_t global_mask = map->get_global_mask (); - buffer->reset_masks (global_mask); -} - static inline void hb_ot_shape_setup_masks (const hb_ot_shape_context_t *c) { @@ -1178,8 +1171,7 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c) _hb_buffer_allocate_unicode_vars (c->buffer); - hb_ot_shape_initialize_masks (c); - hb_set_unicode_props (c->buffer); + hb_set_unicode_props (c->buffer, c->plan->map.get_global_mask ()); hb_insert_dotted_circle (c->buffer, c->font); hb_form_clusters (c->buffer);