More Low-level Optimizations
This test can be made against a value of zero if the inital value
of scaledFraction has 2*dx subtracted from it. Giving, outside the loop:
OffsetScaledFraction = dx + 2*dy - 2*dx = 2*dy - dx
and the inner loop becomes
OffsetScaledFraction += 2*dy
if (OffsetScaledFraction >= 0) {
y = y + 1;
fraction -= 2*dx;
}
We might as well double the values of dy and dx (this can be accomplished
with either an add or a shift outside the loop).
|