* src/raster/ftraster.c (Insert_Y_Turn): Improve flow.

gsoc-craig-2023-final
Alexei Podtelezhnikov 1 year ago
parent fab53f7b1f
commit 09ae6eb677
  1. 32
      src/raster/ftraster.c

@ -609,19 +609,24 @@
static Bool
Insert_Y_Turn( RAS_ARGS Int y )
{
PLong y_turns;
Int n;
Int n = ras.numTurns;
PLong y_turns = ras.maxBuff;
n = ras.numTurns - 1;
y_turns = ras.sizeBuff - ras.numTurns;
/* look for first y value that is <= */
while ( n >= 0 && y < y_turns[n] )
n--;
while ( n-- && y < y_turns[n] )
;
/* if it is <, simply insert it, ignore if == */
if ( n >= 0 && y > y_turns[n] )
if ( n < 0 || y > y_turns[n] )
{
ras.maxBuff--;
if ( ras.maxBuff <= ras.top )
{
ras.error = FT_THROW( Raster_Overflow );
return FAILURE;
}
do
{
Int y2 = (Int)y_turns[n];
@ -629,18 +634,9 @@
y_turns[n] = y;
y = y2;
} while ( --n >= 0 );
} while ( n-- >= 0 );
if ( n < 0 )
{
ras.maxBuff--;
if ( ras.maxBuff <= ras.top )
{
ras.error = FT_THROW( Raster_Overflow );
return FAILURE;
}
ras.numTurns++;
ras.sizeBuff[-ras.numTurns] = y;
}
return SUCCESS;

Loading…
Cancel
Save