Shortening buffer accessors: rename buffer->in_length to buffer->len
authorBehdad Esfahbod <behdad@behdad.org>
Sat, 15 May 2010 02:07:46 +0000 (22:07 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Sat, 15 May 2010 02:07:46 +0000 (22:07 -0400)
src/hb-buffer-private.hh
src/hb-buffer.cc
src/hb-ot-layout-gpos-private.hh
src/hb-ot-layout-gsub-private.hh
src/hb-ot-layout-gsubgpos-private.hh
src/hb-shape.cc

index 9164e1c..40c3787 100644 (file)
@@ -110,7 +110,7 @@ struct _hb_buffer_t {
 
   hb_bool_t    have_output; /* whether we have an output buffer going on */
   hb_bool_t    have_positions; /* whether we have positions */
-  unsigned int in_length;
+  unsigned int len;
   unsigned int out_length;
   unsigned int in_pos;
 
index 64f6144..c2101bb 100644 (file)
@@ -43,7 +43,7 @@ static hb_buffer_t _hb_buffer_nil = {
  *
  * As an optimization, both info and out_info may point to the
  * same piece of memory, which is owned by info.  This remains the
- * case as long as out_length doesn't exceed in_length at any time.
+ * case as long as out_length doesn't exceed len at any time.
  * In that case, swap() is no-op and the glyph operations operate mostly
  * in-place.
  *
@@ -181,7 +181,7 @@ hb_buffer_clear (hb_buffer_t *buffer)
 {
   buffer->have_output = FALSE;
   buffer->have_positions = FALSE;
-  buffer->in_length = 0;
+  buffer->len = 0;
   buffer->out_length = 0;
   buffer->in_pos = 0;
   buffer->out_info = buffer->info;
@@ -224,9 +224,9 @@ hb_buffer_add_glyph (hb_buffer_t    *buffer,
 {
   hb_internal_glyph_info_t *glyph;
 
-  hb_buffer_ensure (buffer, buffer->in_length + 1);
+  hb_buffer_ensure (buffer, buffer->len + 1);
 
-  glyph = &buffer->info[buffer->in_length];
+  glyph = &buffer->info[buffer->len];
   glyph->codepoint = codepoint;
   glyph->mask = mask;
   glyph->cluster = cluster;
@@ -234,7 +234,7 @@ hb_buffer_add_glyph (hb_buffer_t    *buffer,
   glyph->lig_id = 0;
   glyph->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
 
-  buffer->in_length++;
+  buffer->len++;
 }
 
 
@@ -262,7 +262,7 @@ hb_buffer_clear_positions (hb_buffer_t *buffer)
     return;
   }
 
-  memset (buffer->pos, 0, sizeof (buffer->pos[0]) * buffer->in_length);
+  memset (buffer->pos, 0, sizeof (buffer->pos[0]) * buffer->len);
 }
 
 void
@@ -281,8 +281,8 @@ _hb_buffer_swap (hb_buffer_t *buffer)
     buffer->pos = (hb_internal_glyph_position_t *) buffer->out_info;
   }
 
-  tmp = buffer->in_length;
-  buffer->in_length = buffer->out_length;
+  tmp = buffer->len;
+  buffer->len = buffer->out_length;
   buffer->out_length = tmp;
 
   buffer->in_pos = 0;
@@ -439,7 +439,7 @@ _hb_buffer_next_glyph (hb_buffer_t *buffer)
 unsigned int
 hb_buffer_get_length (hb_buffer_t *buffer)
 {
-  return buffer->in_length;
+  return buffer->len;
 }
 
 /* Return value valid as long as buffer not modified */
@@ -489,10 +489,10 @@ reverse_range (hb_buffer_t *buffer,
 void
 hb_buffer_reverse (hb_buffer_t *buffer)
 {
-  if (unlikely (!buffer->in_length))
+  if (unlikely (!buffer->len))
     return;
 
-  reverse_range (buffer, 0, buffer->in_length);
+  reverse_range (buffer, 0, buffer->len);
 }
 
 void
@@ -500,12 +500,12 @@ hb_buffer_reverse_clusters (hb_buffer_t *buffer)
 {
   unsigned int i, start, count, last_cluster;
 
-  if (unlikely (!buffer->in_length))
+  if (unlikely (!buffer->len))
     return;
 
   hb_buffer_reverse (buffer);
 
-  count = buffer->in_length;
+  count = buffer->len;
   start = 0;
   last_cluster = buffer->info[0].cluster;
   for (i = 1; i < count; i++) {
index a2501d0..2a66f42 100644 (file)
@@ -619,7 +619,7 @@ struct PairPosFormat1
   inline bool apply (hb_apply_context_t *c) const
   {
     TRACE_APPLY ();
-    unsigned int end = MIN (c->buffer->in_length, c->buffer->in_pos + c->context_length);
+    unsigned int end = MIN (c->buffer->len, c->buffer->in_pos + c->context_length);
     if (unlikely (c->buffer->in_pos + 2 > end))
       return false;
 
@@ -681,7 +681,7 @@ struct PairPosFormat2
   inline bool apply (hb_apply_context_t *c) const
   {
     TRACE_APPLY ();
-    unsigned int end = MIN (c->buffer->in_length, c->buffer->in_pos + c->context_length);
+    unsigned int end = MIN (c->buffer->len, c->buffer->in_pos + c->context_length);
     if (unlikely (c->buffer->in_pos + 2 > end))
       return false;
 
@@ -1529,13 +1529,13 @@ struct PosLookup : Lookup
   {
     bool ret = false;
 
-    if (unlikely (!buffer->in_length))
+    if (unlikely (!buffer->len))
       return false;
 
     layout->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST; /* no last valid glyph for cursive pos. */
 
     buffer->in_pos = 0;
-    while (buffer->in_pos < buffer->in_length)
+    while (buffer->in_pos < buffer->len)
     {
       bool done;
       if (~buffer->info[buffer->in_pos].mask & mask)
index f5b3593..b0b0387 100644 (file)
@@ -367,7 +367,7 @@ struct Ligature
     TRACE_APPLY ();
     unsigned int i, j;
     unsigned int count = component.len;
-    unsigned int end = MIN (c->buffer->in_length, c->buffer->in_pos + c->context_length);
+    unsigned int end = MIN (c->buffer->len, c->buffer->in_pos + c->context_length);
     if (unlikely (c->buffer->in_pos + count > end))
       return false;
 
@@ -820,7 +820,7 @@ struct SubstLookup : Lookup
   {
     bool ret = false;
 
-    if (unlikely (!buffer->in_length))
+    if (unlikely (!buffer->len))
       return false;
 
     if (likely (!is_reverse ()))
@@ -828,7 +828,7 @@ struct SubstLookup : Lookup
        /* in/out forward substitution */
        buffer->clear_output ();
        buffer->in_pos = 0;
-       while (buffer->in_pos < buffer->in_length)
+       while (buffer->in_pos < buffer->len)
        {
          if ((~buffer->info[buffer->in_pos].mask & mask) &&
              apply_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
@@ -843,7 +843,7 @@ struct SubstLookup : Lookup
     else
     {
        /* in-place backward substitution */
-       buffer->in_pos = buffer->in_length - 1;
+       buffer->in_pos = buffer->len - 1;
        do
        {
          if ((~buffer->info[buffer->in_pos].mask & mask) &&
index 4019c93..7183e6e 100644 (file)
@@ -88,7 +88,7 @@ static inline bool match_input (hb_apply_context_t *c,
                                unsigned int *context_length_out)
 {
   unsigned int i, j;
-  unsigned int end = MIN (c->buffer->in_length, c->buffer->in_pos + c->context_length);
+  unsigned int end = MIN (c->buffer->len, c->buffer->in_pos + c->context_length);
   if (unlikely (c->buffer->in_pos + count > end))
     return false;
 
@@ -143,7 +143,7 @@ static inline bool match_lookahead (hb_apply_context_t *c,
                                    unsigned int offset)
 {
   unsigned int i, j;
-  unsigned int end = MIN (c->buffer->in_length, c->buffer->in_pos + c->context_length);
+  unsigned int end = MIN (c->buffer->len, c->buffer->in_pos + c->context_length);
   if (unlikely (c->buffer->in_pos + offset + count > end))
     return false;
 
@@ -185,7 +185,7 @@ static inline bool apply_lookup (hb_apply_context_t *c,
                                 const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
                                 apply_lookup_func_t apply_func)
 {
-  unsigned int end = MIN (c->buffer->in_length, c->buffer->in_pos + c->context_length);
+  unsigned int end = MIN (c->buffer->len, c->buffer->in_pos + c->context_length);
   if (unlikely (c->buffer->in_pos + count > end))
     return false;
 
@@ -520,7 +520,7 @@ static inline bool chain_context_lookup (hb_apply_context_t *c,
 {
   /* First guess */
   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->len ||
                inputCount + lookaheadCount > c->context_length))
     return false;
 
index a6a45e0..0f03109 100644 (file)
@@ -48,7 +48,7 @@ hb_form_clusters (hb_buffer_t *buffer)
 {
   unsigned int count;
 
-  count = buffer->in_length;
+  count = buffer->len;
   for (buffer->in_pos = 1; buffer->in_pos < count; buffer->in_pos++)
     if (buffer->unicode->get_general_category (buffer->info[buffer->in_pos].codepoint) == HB_CATEGORY_NON_SPACING_MARK)
       buffer->info[buffer->in_pos].cluster = buffer->info[buffer->in_pos - 1].cluster;
@@ -82,7 +82,7 @@ hb_mirror_chars (hb_buffer_t *buffer)
   if (HB_DIRECTION_IS_FORWARD (buffer->direction))
     return;
 
-  count = buffer->in_length;
+  count = buffer->len;
   for (buffer->in_pos = 0; buffer->in_pos < count; buffer->in_pos++) {
       buffer->info[buffer->in_pos].codepoint = get_mirroring (buffer->info[buffer->in_pos].codepoint);
   }
@@ -95,9 +95,9 @@ hb_map_glyphs (hb_font_t    *font,
 {
   unsigned int count;
 
-  if (unlikely (!buffer->in_length))
+  if (unlikely (!buffer->len))
     return;
-  count = buffer->in_length - 1;
+  count = buffer->len - 1;
   for (buffer->in_pos = 0; buffer->in_pos < count; buffer->in_pos++) {
     if (unlikely (is_variation_selector (buffer->info[buffer->in_pos + 1].codepoint))) {
       buffer->info[buffer->in_pos].codepoint = hb_font_get_glyph (font, face, buffer->info[buffer->in_pos].codepoint, buffer->info[buffer->in_pos + 1].codepoint);
@@ -154,7 +154,7 @@ hb_position_default (hb_font_t    *font,
 
   hb_buffer_clear_positions (buffer);
 
-  count = buffer->in_length;
+  count = buffer->len;
   for (buffer->in_pos = 0; buffer->in_pos < count; buffer->in_pos++) {
     hb_glyph_metrics_t metrics;
     hb_font_get_glyph_metrics (font, face, buffer->info[buffer->in_pos].codepoint, &metrics);
@@ -193,7 +193,7 @@ hb_truetype_kern (hb_font_t    *font,
   unsigned int count;
 
   /* TODO Check for kern=0 */
-  count = buffer->in_length;
+  count = buffer->len;
   for (buffer->in_pos = 1; buffer->in_pos < count; buffer->in_pos++) {
     hb_position_t kern, kern1, kern2;
     kern = hb_font_get_kerning (font, face, buffer->info[buffer->in_pos - 1].codepoint, buffer->info[buffer->in_pos].codepoint);