include/rtl/math.hxx               |   14 ++------------
 sc/source/filter/excel/xlchart.cxx |    3 +--
 sc/source/filter/excel/xltools.cxx |   13 ++++---------
 3 files changed, 7 insertions(+), 23 deletions(-)

New commits:
commit 40336ee0b4acf4e359fef696c6c2a6b3fa9718e7
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Feb 29 11:14:10 2024 +0600
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Feb 29 07:24:00 2024 +0100

    Simplify a bit
    
    Change-Id: I9fbc43916fe0d7af87001e48854a87636115a1f9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164133
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/include/rtl/math.hxx b/include/rtl/math.hxx
index 661ddf1d131d..604cefcb6b2c 100644
--- a/include/rtl/math.hxx
+++ b/include/rtl/math.hxx
@@ -431,28 +431,18 @@ inline bool isSignBitSet(double d)
  */
 inline void setInf(double * pd, bool bNegative)
 {
-    union
-    {
-        double sd;
-        sal_math_Double md;
-    };
+    sal_math_Double& md = *reinterpret_cast<sal_math_Double*>(pd);
     md.w32_parts.msw = bNegative ? 0xFFF00000 : 0x7FF00000;
     md.w32_parts.lsw = 0;
-    *pd = sd;
 }
 
 /** Set a QNAN.
  */
 inline void setNan(double * pd)
 {
-    union
-    {
-        double sd;
-        sal_math_Double md;
-    };
+    sal_math_Double& md = *reinterpret_cast<sal_math_Double*>(pd);
     md.w32_parts.msw = 0x7FFFFFFF;
     md.w32_parts.lsw = 0xFFFFFFFF;
-    *pd = sd;
 }
 
 /** If a value is a valid argument for sin(), cos(), tan().
diff --git a/sc/source/filter/excel/xlchart.cxx 
b/sc/source/filter/excel/xlchart.cxx
index 011d4578ff6f..c916b9d7dfbd 100644
--- a/sc/source/filter/excel/xlchart.cxx
+++ b/sc/source/filter/excel/xlchart.cxx
@@ -197,8 +197,7 @@ XclChSerTrendLine::XclChSerTrendLine() :
     /*  Set all bits in mfIntercept to 1 (that is -1.#NAN) to indicate that
         there is no interception point. Cannot use ::rtl::math::setNan() here
         cause it misses the sign bit. */
-    sal_math_Double* pDouble = reinterpret_cast< sal_math_Double* >( 
&mfIntercept );
-    pDouble->w32_parts.msw = pDouble->w32_parts.lsw = 0xFFFFFFFF;
+    reinterpret_cast<sal_math_Double*>(&mfIntercept)->intrep = 
0xFFFFFFFFFFFFFFFF;
 }
 
 XclChSerErrorBar::XclChSerErrorBar() :
diff --git a/sc/source/filter/excel/xltools.cxx 
b/sc/source/filter/excel/xltools.cxx
index 3a69e7da06a7..35ef279161cb 100644
--- a/sc/source/filter/excel/xltools.cxx
+++ b/sc/source/filter/excel/xltools.cxx
@@ -97,18 +97,13 @@ const XclGuid XclTools::maGuidFileMoniker(
 
 double XclTools::GetDoubleFromRK( sal_Int32 nRKValue )
 {
-    union
-    {
-        double fVal;
-        sal_math_Double smD;
-    };
-    fVal = 0.0;
+    sal_math_Double smD{};
 
     if( ::get_flag( nRKValue, EXC_RK_INTFLAG ) )
     {
         sal_Int32 nTemp = nRKValue >> 2;
         ::set_flag< sal_Int32 >( nTemp, 0xE0000000, nRKValue < 0 );
-        fVal = nTemp;
+        smD.value = nTemp;
     }
     else
     {
@@ -116,9 +111,9 @@ double XclTools::GetDoubleFromRK( sal_Int32 nRKValue )
     }
 
     if( ::get_flag( nRKValue, EXC_RK_100FLAG ) )
-        fVal /= 100.0;
+        smD.value /= 100.0;
 
-    return fVal;
+    return smD.value;
 }
 
 bool XclTools::GetRKFromDouble( sal_Int32& rnRKValue, double fValue )

Reply via email to