Commit f44ddfda45eaded9956f46ad1c531b61d8447eef

Alexei Podtelezhnikov 2016-08-30T23:21:23

[smooth] Streamline pixmap drawing a bit more. Zero coverage is unlikely (1 out of 256) to warrant checking. This gives 0.5% speed improvement in dendering simple glyphs. * src/smooth/ftgrays.c (gray_hline, gray_render_span): Remove checks.

diff --git a/ChangeLog b/ChangeLog
index c3cb03a..7174508 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-08-30  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+	[smooth] Streamline pixmap drawing a bit more.
+
+	Zero coverage is unlikely (1 out of 256) to warrant checking. This
+	gives 0.5% speed improvement in dendering simple glyphs.
+
+	* src/smooth/ftgrays.c (gray_hline, gray_render_span): Remove checks.
+
 2016-08-29  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
 	[smooth] Streamline pixmap drawing.
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 814749b..7034f16 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -1281,31 +1281,26 @@ typedef ptrdiff_t  FT_PtrDist;
 
     for ( ; count > 0; count--, spans++ )
     {
-      unsigned char  coverage = spans->coverage;
+      unsigned char   coverage = spans->coverage;
+      unsigned char*  q = p + spans->x;
 
 
-      if ( coverage )
+      /* For small-spans it is faster to do it by ourselves than
+       * calling `memset'.  This is mainly due to the cost of the
+       * function call.
+       */
+      switch ( spans->len )
       {
-        unsigned char*  q = p + spans->x;
-
-
-        /* For small-spans it is faster to do it by ourselves than
-         * calling `memset'.  This is mainly due to the cost of the
-         * function call.
-         */
-        switch ( spans->len )
-        {
-        case 7: *q++ = coverage;
-        case 6: *q++ = coverage;
-        case 5: *q++ = coverage;
-        case 4: *q++ = coverage;
-        case 3: *q++ = coverage;
-        case 2: *q++ = coverage;
-        case 1: *q   = coverage;
-        case 0: break;
-        default:
-          FT_MEM_SET( q, coverage, spans->len );
-        }
+      case 7: *q++ = coverage;
+      case 6: *q++ = coverage;
+      case 5: *q++ = coverage;
+      case 4: *q++ = coverage;
+      case 3: *q++ = coverage;
+      case 2: *q++ = coverage;
+      case 1: *q   = coverage;
+      case 0: break;
+      default:
+        FT_MEM_SET( q, coverage, spans->len );
       }
     }
   }
@@ -1317,7 +1312,8 @@ typedef ptrdiff_t  FT_PtrDist;
                        TArea   area,
                        TCoord  acount )
   {
-    int  coverage;
+    int      coverage;
+    FT_Span  span;
 
 
     /* compute the coverage line's coverage, depending on the    */
@@ -1346,17 +1342,11 @@ typedef ptrdiff_t  FT_PtrDist;
         coverage = 255;
     }
 
-    if ( coverage )
-    {
-      FT_Span  span;
-
+    span.x        = (short)( x + ras.min_ex );
+    span.len      = (unsigned short)acount;
+    span.coverage = (unsigned char)coverage;
 
-      span.x        = (short)( x + ras.min_ex );
-      span.len      = (unsigned short)acount;
-      span.coverage = (unsigned char)coverage;
-
-      ras.render_span( y + ras.min_ey, 1, &span, ras.render_span_data );
-    }
+    ras.render_span( y + ras.min_ey, 1, &span, ras.render_span_data );
   }