svx/source/dialog/dialcontrol.cxx |    2 +-
 tools/source/generic/poly.cxx     |    2 +-
 vcl/source/treelist/imap.cxx      |    9 +--------
 vcl/source/treelist/imap2.cxx     |    3 +--
 4 files changed, 4 insertions(+), 12 deletions(-)

New commits:
commit 1b44a4c558fdf597bf66c1c671248ca58e145e9e
Author:     Leonid Ryzhov <leoryz...@gmail.com>
AuthorDate: Thu Jan 5 18:14:16 2023 +0300
Commit:     Hossein <hoss...@libreoffice.org>
CommitDate: Mon Jan 9 09:18:12 2023 +0000

    tdf#147906 Use std::hypot for Pythagorean addition
    
    Change-Id: Ia325af8d9a23e617eb62e6cecab0aa68f1d206f8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145089
    Tested-by: Jenkins
    Reviewed-by: Hossein <hoss...@libreoffice.org>

diff --git a/svx/source/dialog/dialcontrol.cxx 
b/svx/source/dialog/dialcontrol.cxx
index e6c7c8e43b3b..d16c0b4d92cc 100644
--- a/svx/source/dialog/dialcontrol.cxx
+++ b/svx/source/dialog/dialcontrol.cxx
@@ -448,7 +448,7 @@ void DialControl::HandleMouseEvent( const Point& rPos, bool 
bInitial )
 {
     tools::Long nX = rPos.X() - mpImpl->mnCenterX;
     tools::Long nY = mpImpl->mnCenterY - rPos.Y();
-    double fH = sqrt( static_cast< double >( nX ) * nX + static_cast< double 
>( nY ) * nY );
+    double fH = std::hypot( nX, nY );
     if( fH != 0.0 )
     {
         double fAngle = acos( nX / fH );
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 2665b0381571..efd04b9b3e3d 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -1037,7 +1037,7 @@ double Polygon::CalcDistance( sal_uInt16 nP1, sal_uInt16 
nP2 ) const
     const double fDx = rP2.X() - rP1.X();
     const double fDy = rP2.Y() - rP1.Y();
 
-    return sqrt( fDx * fDx + fDy * fDy );
+    return std::hypot( fDx, fDy );
 }
 
 void Polygon::Optimize( PolyOptimizeFlags nOptimizeFlags )
diff --git a/vcl/source/treelist/imap.cxx b/vcl/source/treelist/imap.cxx
index 034d9655f7af..09cc9f4f0647 100644
--- a/vcl/source/treelist/imap.cxx
+++ b/vcl/source/treelist/imap.cxx
@@ -320,15 +320,8 @@ IMapObjectType IMapCircleObject::GetType() const
 bool IMapCircleObject::IsHit( const Point& rPoint ) const
 {
     const Point aPoint( aCenter - rPoint );
-    bool        bRet = false;
 
-    if ( static_cast<sal_Int32>(sqrt( static_cast<double>(aPoint.X()) * 
aPoint.X() +
-                       aPoint.Y() * aPoint.Y() )) <= nRadius )
-    {
-        bRet = true;
-    }
-
-    return bRet;
+    return static_cast<sal_Int32>( std::hypot( aPoint.X(), aPoint.Y() ) ) <= 
nRadius;
 }
 
 Point IMapCircleObject::GetCenter( bool bPixelCoords ) const
diff --git a/vcl/source/treelist/imap2.cxx b/vcl/source/treelist/imap2.cxx
index 980dae3eee48..f0e3c6913f47 100644
--- a/vcl/source/treelist/imap2.cxx
+++ b/vcl/source/treelist/imap2.cxx
@@ -411,8 +411,7 @@ void ImageMap::ImpReadNCSALine( std::string_view rLine )
         const OUString  aURL( ImpReadNCSAURL( &pStr ) );
         const Point     aCenter( ImpReadNCSACoords( &pStr ) );
         const Point     aDX( aCenter - ImpReadNCSACoords( &pStr ) );
-        tools::Long            nRadius = static_cast<tools::Long>(sqrt( 
static_cast<double>(aDX.X()) * aDX.X() +
-                                               static_cast<double>(aDX.Y()) * 
aDX.Y() ));
+        tools::Long            nRadius = static_cast<tools::Long>(std::hypot( 
aDX.X(), aDX.Y()));
 
         maList.emplace_back( new IMapCircleObject( aCenter, nRadius, aURL, 
OUString(), OUString(), OUString(), OUString() ) );
     }

Reply via email to