[Libreoffice-commits] core.git: include/tools tools/qa tools/source

Noel (via logerrit) logerrit at kemper.freedesktop.org
Tue Nov 17 13:31:42 UTC 2020


 include/tools/bigint.hxx         |    8 +-------
 tools/qa/cppunit/test_bigint.cxx |    6 ------
 tools/source/generic/bigint.cxx  |    7 -------
 3 files changed, 1 insertion(+), 20 deletions(-)

New commits:
commit 9536098ff107f1096e7f710c6f1e76c5659a5482
Author:     Noel <noelgrandin at gmail.com>
AuthorDate: Tue Nov 17 10:15:11 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Nov 17 14:31:01 2020 +0100

    simplify BigInt, remove isSet
    
    no need for such a thing to be "nullable", just default it to zero,
    as one would be expect for such a type.
    
    Change-Id: Ic8b78ca3288355c90820135b9ced2c865ff7606e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105970
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/tools/bigint.hxx b/include/tools/bigint.hxx
index db8c3bcd1b1c..a8d8575fb53b 100644
--- a/include/tools/bigint.hxx
+++ b/include/tools/bigint.hxx
@@ -32,8 +32,7 @@ private:
     sal_uInt16      nNum[MAX_DIGITS];
     sal_uInt8       nLen        : 5;    // current length
     bool            bIsNeg      : 1,    // Is Sign negative?
-                    bIsBig      : 1,    // sal_True == BigInt
-                    bIsSet      : 1;    // Not "Null" (not "not 0")
+                    bIsBig      : 1;    // if true , value is in nNum array
 
     TOOLS_DLLPRIVATE void MakeBigInt(BigInt const &);
     TOOLS_DLLPRIVATE void Normalize();
@@ -53,7 +52,6 @@ public:
         , nLen(0)
         , bIsNeg(false)
         , bIsBig(false)
-        , bIsSet(false)
     {
     }
 
@@ -62,7 +60,6 @@ public:
         , nLen(0)
         , bIsNeg(false)
         , bIsBig(false)
-        , bIsSet(true)
     {
     }
 
@@ -72,7 +69,6 @@ public:
         , nLen(0)
         , bIsNeg(false)
         , bIsBig(false)
-        , bIsSet(true)
     {
     }
 #endif
@@ -92,7 +88,6 @@ public:
     operator        tools::Long() const;
 #endif
 
-    bool            IsSet() const { return bIsSet; }
     bool            IsNeg() const;
     bool            IsZero() const;
     bool            IsLong() const { return !bIsBig; }
@@ -169,7 +164,6 @@ inline BigInt::operator tools::Long() const
 
 inline BigInt& BigInt::operator =( sal_Int32 nValue )
 {
-    bIsSet = true;
     bIsBig = false;
     nVal   = nValue;
 
diff --git a/tools/qa/cppunit/test_bigint.cxx b/tools/qa/cppunit/test_bigint.cxx
index a91d16f93def..140562df0e23 100644
--- a/tools/qa/cppunit/test_bigint.cxx
+++ b/tools/qa/cppunit/test_bigint.cxx
@@ -39,7 +39,6 @@ void BigIntTest::testConstructionFromLongLong()
     // small positive number
     {
         BigInt bi(static_cast<sal_Int64>(42));
-        CPPUNIT_ASSERT(bi.IsSet());
         CPPUNIT_ASSERT(!bi.IsZero());
         CPPUNIT_ASSERT(!bi.IsNeg());
         CPPUNIT_ASSERT(bi.IsLong());
@@ -49,7 +48,6 @@ void BigIntTest::testConstructionFromLongLong()
     // small negative number
     {
         BigInt bi(static_cast<sal_Int64>(-42));
-        CPPUNIT_ASSERT(bi.IsSet());
         CPPUNIT_ASSERT(!bi.IsZero());
         CPPUNIT_ASSERT(bi.IsNeg());
         CPPUNIT_ASSERT(bi.IsLong());
@@ -60,7 +58,6 @@ void BigIntTest::testConstructionFromLongLong()
     // positive number just fitting to sal_Int32
     {
         BigInt bi(static_cast<sal_Int64>(std::numeric_limits<sal_Int32>::max()));
-        CPPUNIT_ASSERT(bi.IsSet());
         CPPUNIT_ASSERT(!bi.IsZero());
         CPPUNIT_ASSERT(!bi.IsNeg());
         CPPUNIT_ASSERT(bi.IsLong());
@@ -70,7 +67,6 @@ void BigIntTest::testConstructionFromLongLong()
     // negative number just fitting to sal_Int32
     {
         BigInt bi(static_cast<sal_Int64>(std::numeric_limits<sal_Int32>::min()));
-        CPPUNIT_ASSERT(bi.IsSet());
         CPPUNIT_ASSERT(!bi.IsZero());
         CPPUNIT_ASSERT(bi.IsNeg());
         CPPUNIT_ASSERT(bi.IsLong());
@@ -80,7 +76,6 @@ void BigIntTest::testConstructionFromLongLong()
     // positive number not fitting to sal_Int32
     {
         BigInt bi(static_cast<sal_Int64>(std::numeric_limits<sal_Int32>::max()) + 1);
-        CPPUNIT_ASSERT(bi.IsSet());
         CPPUNIT_ASSERT(!bi.IsZero());
         CPPUNIT_ASSERT(!bi.IsNeg());
         CPPUNIT_ASSERT(!bi.IsLong());
@@ -89,7 +84,6 @@ void BigIntTest::testConstructionFromLongLong()
     // negative number not fitting to sal_Int32
     {
         BigInt bi(static_cast<sal_Int64>(std::numeric_limits<sal_Int32>::min()) - 1);
-        CPPUNIT_ASSERT(bi.IsSet());
         CPPUNIT_ASSERT(!bi.IsZero());
         CPPUNIT_ASSERT(bi.IsNeg());
         CPPUNIT_ASSERT(!bi.IsLong());
diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx
index d90ac2447fa1..62350a30c311 100644
--- a/tools/source/generic/bigint.cxx
+++ b/tools/source/generic/bigint.cxx
@@ -477,7 +477,6 @@ BigInt::BigInt( const BigInt& rBigInt )
         memcpy( static_cast<void*>(this), static_cast<const void*>(&rBigInt), sizeof( BigInt ) );
     else
     {
-        bIsSet = rBigInt.bIsSet;
         bIsBig = false;
         nVal   = rBigInt.nVal;
     }
@@ -486,7 +485,6 @@ BigInt::BigInt( const BigInt& rBigInt )
 BigInt::BigInt( const OUString& rString )
     : nLen(0)
 {
-    bIsSet = true;
     bIsNeg = false;
     bIsBig = false;
     nVal   = 0;
@@ -513,8 +511,6 @@ BigInt::BigInt( const OUString& rString )
 BigInt::BigInt( double nValue )
     : nVal(0)
 {
-    bIsSet = true;
-
     if ( nValue < 0 )
     {
         nValue *= -1;
@@ -557,7 +553,6 @@ BigInt::BigInt( double nValue )
 BigInt::BigInt( sal_uInt32 nValue )
     : nVal(0)
 {
-    bIsSet  = true;
     if ( nValue & 0x80000000U )
     {
         bIsBig  = true;
@@ -578,7 +573,6 @@ BigInt::BigInt( sal_uInt32 nValue )
 BigInt::BigInt( sal_Int64 nValue )
     : nVal(0)
 {
-    bIsSet = true;
     bIsNeg = nValue < 0;
     nLen = 0;
 
@@ -632,7 +626,6 @@ BigInt& BigInt::operator=( const BigInt& rBigInt )
         memcpy( static_cast<void*>(this), static_cast<const void*>(&rBigInt), sizeof( BigInt ) );
     else
     {
-        bIsSet = rBigInt.bIsSet;
         bIsBig = false;
         nVal   = rBigInt.nVal;
     }


More information about the Libreoffice-commits mailing list