Merge buffer->out_pos and buffer->out_length

This commit is contained in:
Behdad Esfahbod 2010-05-14 21:58:22 -04:00
parent 22f668eb9a
commit 8e6b6bb293
4 changed files with 24 additions and 33 deletions

View File

@ -113,7 +113,6 @@ struct _hb_buffer_t {
unsigned int in_length; unsigned int in_length;
unsigned int out_length; unsigned int out_length;
unsigned int in_pos; unsigned int in_pos;
unsigned int out_pos; /* out_length and out_pos are actually always the same */
hb_internal_glyph_info_t *in_string; hb_internal_glyph_info_t *in_string;
hb_internal_glyph_info_t *out_string; hb_internal_glyph_info_t *out_string;

View File

@ -184,7 +184,6 @@ hb_buffer_clear (hb_buffer_t *buffer)
buffer->in_length = 0; buffer->in_length = 0;
buffer->out_length = 0; buffer->out_length = 0;
buffer->in_pos = 0; buffer->in_pos = 0;
buffer->out_pos = 0;
buffer->out_string = buffer->in_string; buffer->out_string = buffer->in_string;
buffer->max_lig_id = 0; buffer->max_lig_id = 0;
} }
@ -247,7 +246,6 @@ _hb_buffer_clear_output (hb_buffer_t *buffer)
buffer->have_output = TRUE; buffer->have_output = TRUE;
buffer->have_positions = FALSE; buffer->have_positions = FALSE;
buffer->out_length = 0; buffer->out_length = 0;
buffer->out_pos = 0;
buffer->out_string = buffer->in_string; buffer->out_string = buffer->in_string;
} }
@ -287,9 +285,7 @@ _hb_buffer_swap (hb_buffer_t *buffer)
buffer->in_length = buffer->out_length; buffer->in_length = buffer->out_length;
buffer->out_length = tmp; buffer->out_length = tmp;
tmp = buffer->in_pos; buffer->in_pos = 0;
buffer->in_pos = buffer->out_pos;
buffer->out_pos = tmp;
} }
/* The following function copies `num_out' elements from `glyph_data' /* The following function copies `num_out' elements from `glyph_data'
@ -325,9 +321,9 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
unsigned int cluster; unsigned int cluster;
if (buffer->out_string != buffer->in_string || if (buffer->out_string != buffer->in_string ||
buffer->out_pos + num_out > buffer->in_pos + num_in) buffer->out_length + num_out > buffer->in_pos + num_in)
{ {
hb_buffer_ensure_separate (buffer, buffer->out_pos + num_out); hb_buffer_ensure_separate (buffer, buffer->out_length + num_out);
} }
mask = buffer->in_string[buffer->in_pos].mask; mask = buffer->in_string[buffer->in_pos].mask;
@ -339,7 +335,7 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
for (i = 0; i < num_out; i++) for (i = 0; i < num_out; i++)
{ {
hb_internal_glyph_info_t *info = &buffer->out_string[buffer->out_pos + i]; hb_internal_glyph_info_t *info = &buffer->out_string[buffer->out_length + i];
info->codepoint = glyph_data[i]; info->codepoint = glyph_data[i];
info->mask = mask; info->mask = mask;
info->cluster = cluster; info->cluster = cluster;
@ -349,8 +345,7 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
} }
buffer->in_pos += num_in; buffer->in_pos += num_in;
buffer->out_pos += num_out; buffer->out_length += num_out;
buffer->out_length = buffer->out_pos;
} }
void void
@ -366,9 +361,9 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
unsigned int cluster; unsigned int cluster;
if (buffer->out_string != buffer->in_string || if (buffer->out_string != buffer->in_string ||
buffer->out_pos + num_out > buffer->in_pos + num_in) buffer->out_length + num_out > buffer->in_pos + num_in)
{ {
hb_buffer_ensure_separate (buffer, buffer->out_pos + num_out); hb_buffer_ensure_separate (buffer, buffer->out_length + num_out);
} }
mask = buffer->in_string[buffer->in_pos].mask; mask = buffer->in_string[buffer->in_pos].mask;
@ -380,7 +375,7 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
for (i = 0; i < num_out; i++) for (i = 0; i < num_out; i++)
{ {
hb_internal_glyph_info_t *info = &buffer->out_string[buffer->out_pos + i]; hb_internal_glyph_info_t *info = &buffer->out_string[buffer->out_length + i];
info->codepoint = hb_be_uint16 (glyph_data_be[i]); info->codepoint = hb_be_uint16 (glyph_data_be[i]);
info->mask = mask; info->mask = mask;
info->cluster = cluster; info->cluster = cluster;
@ -390,8 +385,7 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
} }
buffer->in_pos += num_in; buffer->in_pos += num_in;
buffer->out_pos += num_out; buffer->out_length += num_out;
buffer->out_length = buffer->out_pos;
} }
void void
@ -404,13 +398,13 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
if (buffer->out_string != buffer->in_string) if (buffer->out_string != buffer->in_string)
{ {
hb_buffer_ensure (buffer, buffer->out_pos + 1); hb_buffer_ensure (buffer, buffer->out_length + 1);
buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos]; buffer->out_string[buffer->out_length] = buffer->in_string[buffer->in_pos];
} }
else if (buffer->out_pos != buffer->in_pos) else if (buffer->out_length != buffer->in_pos)
buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos]; buffer->out_string[buffer->out_length] = buffer->in_string[buffer->in_pos];
info = &buffer->out_string[buffer->out_pos]; info = &buffer->out_string[buffer->out_length];
info->codepoint = glyph_index; info->codepoint = glyph_index;
if (component != 0xFFFF) if (component != 0xFFFF)
info->component = component; info->component = component;
@ -419,8 +413,7 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
buffer->in_pos++; buffer->in_pos++;
buffer->out_pos++; buffer->out_length++;
buffer->out_length = buffer->out_pos;
} }
void void
@ -430,14 +423,13 @@ _hb_buffer_next_glyph (hb_buffer_t *buffer)
{ {
if (buffer->out_string != buffer->in_string) if (buffer->out_string != buffer->in_string)
{ {
hb_buffer_ensure (buffer, buffer->out_pos + 1); hb_buffer_ensure (buffer, buffer->out_length + 1);
buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos]; buffer->out_string[buffer->out_length] = buffer->in_string[buffer->in_pos];
} }
else if (buffer->out_pos != buffer->in_pos) else if (buffer->out_length != buffer->in_pos)
buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos]; buffer->out_string[buffer->out_length] = buffer->in_string[buffer->in_pos];
buffer->out_pos++; buffer->out_length++;
buffer->out_length = buffer->out_pos;
} }
buffer->in_pos++; buffer->in_pos++;

View File

@ -289,7 +289,7 @@ struct AlternateSubstFormat1
/* XXX callback to user to choose alternate /* XXX callback to user to choose alternate
if (c->layout->face->altfunc) if (c->layout->face->altfunc)
alt_index = (c->layout->face->altfunc)(c->layout->layout, c->buffer, alt_index = (c->layout->face->altfunc)(c->layout->layout, c->buffer,
c->buffer->out_pos, glyph_id, c->buffer->out_length, glyph_id,
alt_set.len, alt_set.array); alt_set.len, alt_set.array);
*/ */

View File

@ -116,10 +116,10 @@ static inline bool match_backtrack (hb_apply_context_t *c,
match_func_t match_func, match_func_t match_func,
const void *match_data) const void *match_data)
{ {
if (unlikely (c->buffer->out_pos < count)) if (unlikely (c->buffer->out_length < count))
return false; return false;
for (unsigned int i = 0, j = c->buffer->out_pos - 1; i < count; i++, j--) for (unsigned int i = 0, j = c->buffer->out_length - 1; i < count; i++, j--)
{ {
while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->out_string[j], c->lookup_flag, NULL)) while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->out_string[j], c->lookup_flag, NULL))
{ {
@ -519,7 +519,7 @@ static inline bool chain_context_lookup (hb_apply_context_t *c,
ChainContextLookupContext &lookup_context) ChainContextLookupContext &lookup_context)
{ {
/* First guess */ /* First guess */
if (unlikely (c->buffer->out_pos < backtrackCount || if (unlikely (c->buffer->out_length < backtrackCount ||
c->buffer->in_pos + inputCount + lookaheadCount > c->buffer->in_length || c->buffer->in_pos + inputCount + lookaheadCount > c->buffer->in_length ||
inputCount + lookaheadCount > c->context_length)) inputCount + lookaheadCount > c->context_length))
return false; return false;