[buffer] Group shape-related members together

This commit is contained in:
Behdad Esfahbod 2022-01-04 07:26:53 -07:00
parent 52f5711ed0
commit 43be5ba442
4 changed files with 12 additions and 14 deletions

View File

@ -301,10 +301,9 @@ hb_buffer_t::clear ()
memset (context, 0, sizeof context);
memset (context_len, 0, sizeof context_len);
scratch_flags = HB_BUFFER_SCRATCH_FLAG_DEFAULT;
serial = 0;
deallocate_var_all ();
serial = 0;
scratch_flags = HB_BUFFER_SCRATCH_FLAG_DEFAULT;
}
void

View File

@ -129,11 +129,14 @@ struct hb_buffer_t
* Not part of content.
*/
#ifndef HB_NDEBUG
uint8_t allocated_var_bits;
#endif
uint8_t serial;
hb_buffer_scratch_flags_t scratch_flags; /* Have space-fallback, etc. */
unsigned int serial;
unsigned int max_len; /* Maximum allowed len. */
int max_ops; /* Maximum allowed operations. */
/* The bits here reflect current allocations of the bytes in glyph_info_t's var1 and var2. */
/* Debugging API */
#ifndef HB_NO_BUFFER_MESSAGE
@ -145,11 +148,6 @@ struct hb_buffer_t
static constexpr unsigned message_depth = 0u;
#endif
/* Internal debugging. */
/* The bits here reflect current allocations of the bytes in glyph_info_t's var1 and var2. */
#ifndef HB_NDEBUG
uint8_t allocated_var_bits;
#endif
/* Methods */
@ -207,7 +205,7 @@ struct hb_buffer_t
unsigned int backtrack_len () const { return have_output ? out_len : idx; }
unsigned int lookahead_len () const { return len - idx; }
unsigned int next_serial () { return serial++; }
uint8_t next_serial () { return ++serial ? serial : ++serial; }
HB_INTERNAL void add (hb_codepoint_t codepoint,
unsigned int cluster);

View File

@ -482,10 +482,9 @@ _hb_glyph_info_get_lig_num_comps (const hb_glyph_info_t *info)
}
static inline uint8_t
_hb_allocate_lig_id (hb_buffer_t *buffer) {
_hb_allocate_lig_id (hb_buffer_t *buffer)
{
uint8_t lig_id = buffer->next_serial () & 0x07;
if (unlikely (!lig_id))
lig_id = _hb_allocate_lig_id (buffer); /* in case of overflow */
return lig_id;
}

View File

@ -1146,6 +1146,7 @@ static void
hb_ot_shape_internal (hb_ot_shape_context_t *c)
{
c->buffer->deallocate_var_all ();
c->buffer->serial = 0;
c->buffer->scratch_flags = HB_BUFFER_SCRATCH_FLAG_DEFAULT;
if (likely (!hb_unsigned_mul_overflows (c->buffer->len, HB_BUFFER_MAX_LEN_FACTOR)))
{
@ -1191,6 +1192,7 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c)
c->buffer->max_len = HB_BUFFER_MAX_LEN_DEFAULT;
c->buffer->max_ops = HB_BUFFER_MAX_OPS_DEFAULT;
c->buffer->deallocate_var_all ();
c->buffer->serial = 0;
}