[OTLayout] Make MultipleSubst in-place for sequences of len=1
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 2 May 2013 18:44:45 +0000 (14:44 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Thu, 2 May 2013 19:39:16 +0000 (15:39 -0400)
src/hb-ot-layout-gsub-table.hh

index d25a0d3..3b6635b 100644 (file)
@@ -275,11 +275,18 @@ struct Sequence
     unsigned int klass = c->buffer->cur().glyph_props() &
                         HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE ? HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH : 0;
     unsigned int count = substitute.len;
-    for (unsigned int i = 0; i < count; i++) {
-      set_lig_props_for_component (c->buffer->cur(), i);
-      c->output_glyph (substitute.array[i], klass);
+    if (count == 1) /* Special-case to make it in-place. */
+    {
+      c->replace_glyph (substitute.array[0]);
+    }
+    else
+    {
+      for (unsigned int i = 0; i < count; i++) {
+       set_lig_props_for_component (c->buffer->cur(), i);
+       c->output_glyph (substitute.array[i], klass);
+      }
+      c->buffer->skip_glyph ();
     }
-    c->buffer->skip_glyph ();
 
     return TRACE_RETURN (true);
   }