summaryrefslogtreecommitdiff
path: root/basegfx
diff options
context:
space:
mode:
authorJochen Nitschke <j.nitschke+logerrit@ok.de>2017-05-07 23:11:41 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-05-08 02:12:04 +0200
commitc3e0b7dd4e7b1d33b8555e0acdf9f44cfc043ca2 (patch)
tree1a426d19d5ef7f5d4f342c5f8d2263b53a847cfa /basegfx
parent8da106529e85981ce37fbbd18160023c26cc7129 (diff)
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@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basegfx')
-rw-r--r--basegfx/source/curve/b2dcubicbezier.cxx75
1 files changed, 34 insertions, 41 deletions
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;