From 5a6dc87240905f0e55568678e0fbf93a51242051 Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Fri, 4 Sep 2015 23:14:46 -0400 Subject: [PATCH] [raster,smooth] Microoptimizations. * src/raster/ftraster.c (Insert_Y_Turn, Finalize_Profile_Table, Beziier_Up, ): Use do-while loops. * src/smooth/ftgrays.c (gray_render_scanline, gray_render_line, gray_convert_glyph): Ditto. --- ChangeLog | 10 ++++++++++ src/raster/ftraster.c | 14 ++++++-------- src/smooth/ftgrays.c | 12 ++++++------ 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 977473a77..a6e6db36d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2015-09-04 Alexei Podtelezhnikov + + [raster,smooth] Microoptimizations. + + * src/raster/ftraster.c (Insert_Y_Turn, Finalize_Profile_Table, + Beziier_Up, ): Use do-while loops. + + * src/smooth/ftgrays.c (gray_render_scanline, gray_render_line, + gray_convert_glyph): Ditto. + 2015-09-04 Werner Lemberg [autofit] Redesign code ranges (2/2). diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c index 8e9c79426..1c51f912e 100644 --- a/src/raster/ftraster.c +++ b/src/raster/ftraster.c @@ -801,15 +801,14 @@ /* if it is <, simply insert it, ignore if == */ if ( n >= 0 && y > y_turns[n] ) - while ( n >= 0 ) + do { Int y2 = (Int)y_turns[n]; y_turns[n] = y; y = y2; - n--; - } + } while ( --n >= 0 ); if ( n < 0 ) { @@ -850,7 +849,7 @@ if ( n > 1 && p ) { - while ( n > 0 ) + do { Int bottom, top; @@ -878,8 +877,7 @@ return FAILURE; p = p->link; - n--; - } + } while ( --n ); } else ras.fProfile = NULL; @@ -1250,7 +1248,7 @@ start_arc = arc; - while ( arc >= start_arc && e <= e2 ) + do { ras.joint = FALSE; @@ -1283,7 +1281,7 @@ } arc -= degree; } - } + } while ( arc >= start_arc && e <= e2 ); Fin: ras.top = top; diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c index a9317e914..e4559b9d1 100644 --- a/src/smooth/ftgrays.c +++ b/src/smooth/ftgrays.c @@ -758,7 +758,7 @@ typedef ptrdiff_t FT_PtrDist; mod -= (int)dx; - while ( ex1 != ex2 ) + do { delta = lift; mod += rem; @@ -773,7 +773,7 @@ typedef ptrdiff_t FT_PtrDist; y1 += delta; ex1 += incr; gray_set_cell( RAS_VAR_ ex1, ey ); - } + } while ( ex1 != ex2 ); } delta = y2 - y1; @@ -896,7 +896,7 @@ typedef ptrdiff_t FT_PtrDist; FT_DIV_MOD( int, p, dy, lift, rem ); mod -= (int)dy; - while ( ey1 != ey2 ) + do { delta = lift; mod += rem; @@ -914,7 +914,7 @@ typedef ptrdiff_t FT_PtrDist; ey1 += incr; gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 ); - } + } while ( ey1 != ey2 ); } gray_render_scanline( RAS_VAR_ ey1, x, @@ -1847,7 +1847,7 @@ typedef ptrdiff_t FT_PtrDist; bands[0].max = max; band = bands; - while ( band >= bands ) + do { TPos bottom, top, middle; int error; @@ -1923,7 +1923,7 @@ typedef ptrdiff_t FT_PtrDist; band[0].min = middle; band[0].max = top; band++; - } + } while ( band >= bands ); } if ( ras.band_shoot > 8 && ras.band_size > 16 )