[layout] Remove some unnecessary checks in skippy
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 29 Jan 2015 10:38:01 +0000 (11:38 +0100)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 25 Feb 2015 23:43:26 +0000 (15:43 -0800)
src/hb-ot-layout-gpos-table.hh
src/hb-ot-layout-gsubgpos-private.hh

index 9516ae6..ea59237 100644 (file)
@@ -685,7 +685,6 @@ struct PairPosFormat1
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
     hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, buffer->idx, 1);
-    if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
     if (!skippy_iter.next ()) return TRACE_RETURN (false);
 
     return TRACE_RETURN ((this+pairSet[index]).apply (c, &valueFormat1, skippy_iter.idx));
@@ -755,7 +754,6 @@ struct PairPosFormat2
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
     hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, buffer->idx, 1);
-    if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
     if (!skippy_iter.next ()) return TRACE_RETURN (false);
 
     unsigned int len1 = valueFormat1.get_len ();
@@ -905,7 +903,6 @@ struct CursivePosFormat1
     if (!this_record.exitAnchor) return TRACE_RETURN (false);
 
     hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, buffer->idx, 1);
-    if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
     if (!skippy_iter.next ()) return TRACE_RETURN (false);
 
     const EntryExitRecord &next_record = entryExitRecord[(this+coverage).get_coverage  (buffer->info[skippy_iter.idx].codepoint)];
index 332a7e7..6c1b5d9 100644 (file)
@@ -420,12 +420,11 @@ struct hb_apply_context_t
       match_glyph_data = glyph_data;
     }
 
-    inline bool has_no_chance (void) const { return unlikely (num_items && idx + num_items >= end); }
     inline void reject (void) { num_items++; match_glyph_data--; }
     inline bool next (void)
     {
       assert (num_items > 0);
-      while (!has_no_chance ())
+      while (idx + num_items < end)
       {
        idx++;
        const hb_glyph_info_t &info = c->buffer->info[idx];
@@ -489,12 +488,11 @@ struct hb_apply_context_t
       match_glyph_data = glyph_data;
     }
 
-    inline bool has_no_chance (void) const { return unlikely (idx < num_items); }
     inline void reject (void) { num_items++; }
     inline bool prev (void)
     {
       assert (num_items > 0);
-      while (!has_no_chance ())
+      while (idx >= num_items)
       {
        idx--;
        const hb_glyph_info_t &info = c->buffer->out_info[idx];
@@ -741,7 +739,6 @@ static inline bool match_input (hb_apply_context_t *c,
 
   hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, buffer->idx, count - 1);
   skippy_iter.set_match_func (match_func, match_data, input);
-  if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
 
   /*
    * This is perhaps the trickiest part of OpenType...  Remarks:
@@ -910,7 +907,6 @@ static inline bool match_backtrack (hb_apply_context_t *c,
 
   hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, c->buffer->backtrack_len (), count, true);
   skippy_iter.set_match_func (match_func, match_data, backtrack);
-  if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
 
   for (unsigned int i = 0; i < count; i++)
     if (!skippy_iter.prev ())
@@ -930,7 +926,6 @@ static inline bool match_lookahead (hb_apply_context_t *c,
 
   hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, c->buffer->idx + offset - 1, count, true);
   skippy_iter.set_match_func (match_func, match_data, lookahead);
-  if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
 
   for (unsigned int i = 0; i < count; i++)
     if (!skippy_iter.next ())