Kaydet (Commit) c3e0b7dd authored tarafından Jochen Nitschke's avatar Jochen Nitschke Kaydeden (comit) Noel Grandin

cppcheck: knownConditionTrueFalse

remove bDone and simply 'break' the loop when done.

Change-Id: Idf4170083cbda3a783cb52bba9e94d3be512f167
Reviewed-on: https://gerrit.libreoffice.org/37355Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 8da10652
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment