tdf#147906: Use hypot in place of sqrt to avoid overflow

Change-Id: I575bc0c1b6e49ad8dc5db6b3e523ca7e0860aad8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175537
Tested-by: Jenkins
Reviewed-by: Hossein   <hossein@libreoffice.org>
This commit is contained in:
Sakura286
2024-10-24 16:21:52 +08:00
committed by Hossein
parent 182140d53a
commit 060d2fe39f

View File

@@ -839,7 +839,7 @@ static void FitTextOutlinesToShapeOutlines(const tools::PolyPolygon& aOutlines2d
Point aPoint = rOutlinePoly.GetPoint(nPointIdx2)
- rOutlinePoly.GetPoint(nPointIdx1);
double fLen = sqrt(aPoint.X() * aPoint.X() + aPoint.Y() * aPoint.Y());
double fLen = hypot(aPoint.X(), aPoint.Y());
if (fLen > 0)
{
@@ -878,7 +878,7 @@ static void FitTextOutlinesToShapeOutlines(const tools::PolyPolygon& aOutlines2d
//calculate distances between points on the outer outline
const double fDx = vCurOutline[i].X() - vCurOutline[i - 1].X();
const double fDy = vCurOutline[i].Y() - vCurOutline[i - 1].Y();
vCurDistances[i] = sqrt(fDx * fDx + fDy * fDy);
vCurDistances[i] = hypot(fDx, fDy);
}
else
vCurDistances[i] = 0;