[Libreoffice-commits] core.git: basegfx/source
Jochen Nitschke
j.nitschke+logerrit at ok.de
Mon May 8 00:12:39 UTC 2017
basegfx/source/curve/b2dcubicbezier.cxx | 75 ++++++++++++++------------------
1 file changed, 34 insertions(+), 41 deletions(-)
New commits:
commit c3e0b7dd4e7b1d33b8555e0acdf9f44cfc043ca2
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date: Sun May 7 23:11:41 2017 +0200
cppcheck: knownConditionTrueFalse
remove bDone and simply 'break' the loop when done.
Change-Id: Idf4170083cbda3a783cb52bba9e94d3be512f167
Reviewed-on: https://gerrit.libreoffice.org/37355
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx
index 72fabc476327..a709166263e3 100644
--- a/basegfx/source/curve/b2dcubicbezier.cxx
+++ b/basegfx/source/curve/b2dcubicbezier.cxx
@@ -694,23 +694,42 @@ namespace basegfx
// look right and left for even smaller distances
double fStepValue(1.0 / (double)((nPointCount - 1) * 2)); // half the edge step width
double fPosition((double)nSmallestIndex / (double)(nPointCount - 1));
- bool bDone(false);
- while(!bDone)
+ while(true)
{
- if(!bDone)
+ // test left
+ double fPosLeft(fPosition - fStepValue);
+
+ if(fPosLeft < 0.0)
{
- // test left
- double fPosLeft(fPosition - fStepValue);
+ fPosLeft = 0.0;
+ aVector = B2DVector(rTestPoint - maStartPoint);
+ }
+ else
+ {
+ aVector = B2DVector(rTestPoint - interpolatePoint(fPosLeft));
+ }
+
+ fNewQuadDist = aVector.getX() * aVector.getX() + aVector.getY() * aVector.getY();
+
+ if(fTools::less(fNewQuadDist, fQuadDist))
+ {
+ fQuadDist = fNewQuadDist;
+ fPosition = fPosLeft;
+ }
+ else
+ {
+ // test right
+ double fPosRight(fPosition + fStepValue);
- if(fPosLeft < 0.0)
+ if(fPosRight > 1.0)
{
- fPosLeft = 0.0;
- aVector = B2DVector(rTestPoint - maStartPoint);
+ fPosRight = 1.0;
+ aVector = B2DVector(rTestPoint - maEndPoint);
}
else
{
- aVector = B2DVector(rTestPoint - interpolatePoint(fPosLeft));
+ aVector = B2DVector(rTestPoint - interpolatePoint(fPosRight));
}
fNewQuadDist = aVector.getX() * aVector.getX() + aVector.getY() * aVector.getY();
@@ -718,49 +737,23 @@ namespace basegfx
if(fTools::less(fNewQuadDist, fQuadDist))
{
fQuadDist = fNewQuadDist;
- fPosition = fPosLeft;
+ fPosition = fPosRight;
}
else
{
- // test right
- double fPosRight(fPosition + fStepValue);
-
- if(fPosRight > 1.0)
- {
- fPosRight = 1.0;
- aVector = B2DVector(rTestPoint - maEndPoint);
- }
- else
- {
- aVector = B2DVector(rTestPoint - interpolatePoint(fPosRight));
- }
-
- fNewQuadDist = aVector.getX() * aVector.getX() + aVector.getY() * aVector.getY();
-
- if(fTools::less(fNewQuadDist, fQuadDist))
- {
- fQuadDist = fNewQuadDist;
- fPosition = fPosRight;
- }
- else
- {
- // not less left or right, done
- bDone = true;
- }
+ // not less left or right, done
+ break;
}
}
if(0.0 == fPosition || 1.0 == fPosition)
{
// if we are completely left or right, we are done
- bDone = true;
+ break;
}
- if(!bDone)
- {
- // prepare next step value
- fStepValue /= 2.0;
- }
+ // prepare next step value
+ fStepValue /= 2.0;
}
rCut = fPosition;
More information about the Libreoffice-commits
mailing list