sc/source/core/data/column2.cxx       |   34 +++++-------------------
 sc/source/core/tool/sharedformula.cxx |   48 +++++-----------------------------
 2 files changed, 16 insertions(+), 66 deletions(-)

New commits:
commit 980b91d5c850099766bf32dfe28880df8873c046
Author:     Luboš Luňák <[email protected]>
AuthorDate: Wed Feb 16 08:30:24 2022 +0100
Commit:     Luboš Luňák <[email protected]>
CommitDate: Wed Feb 16 21:36:49 2022 +0100

    move simple checks out of DEBUG_COLUMN_STORAGE
    
    These few look like useful assertions and they should be cheap,
    so keep only the extensive checks inside the #if block.
    
    Change-Id: I9e6851d25d8b4d637041c1efe1d9712d410262e0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130003
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <[email protected]>

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 138a1deadd7a..042b1eafbe25 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1658,28 +1658,16 @@ void ScColumn::CellStorageModified()
 
     // TODO: Update column's "last updated" timestamp here.
 
-#if DEBUG_COLUMN_STORAGE
-    if (maCells.size() != MAXROWCOUNT1)
-    {
-        cout << "ScColumn::CellStorageModified: Size of the cell array is 
incorrect." << endl;
-        cout.flush();
-        abort();
-    }
+    assert(sal::static_int_cast<SCROW>(maCells.size()) == 
GetDoc().GetSheetLimits().GetMaxRowCount()
+        && "Size of the cell array is incorrect." );
 
-    if (maCellTextAttrs.size() != MAXROWCOUNT1)
-    {
-        cout << "ScColumn::CellStorageModified: Size of the cell text 
attribute array is incorrect." << endl;
-        cout.flush();
-        abort();
-    }
+    assert(sal::static_int_cast<SCROW>(maCellTextAttrs.size()) == 
GetDoc().GetSheetLimits().GetMaxRowCount()
+        && "Size of the cell text attribute array is incorrect.");
 
-    if (maBroadcasters.size() != MAXROWCOUNT1)
-    {
-        cout << "ScColumn::CellStorageModified: Size of the broadcaster array 
is incorrect." << endl;
-        cout.flush();
-        abort();
-    }
+    assert(sal::static_int_cast<SCROW>(maBroadcasters.size()) == 
GetDoc().GetSheetLimits().GetMaxRowCount()
+        && "Size of the broadcaster array is incorrect.");
 
+#if DEBUG_COLUMN_STORAGE
     // Make sure that these two containers are synchronized wrt empty segments.
     auto lIsEmptyType = [](const auto& rElement) { return rElement.type == 
sc::element_type_empty; };
     // Move to the first empty blocks.
@@ -3312,13 +3300,7 @@ void startListening(
         }
         break;
         default:
-#if DEBUG_COLUMN_STORAGE
-            cout << "ScColumn::StartListening: wrong block type encountered in 
the broadcaster storage." << endl;
-            cout.flush();
-            abort();
-#else
-            ;
-#endif
+            assert(false && "wrong block type encountered in the broadcaster 
storage.");
     }
 }
 
diff --git a/sc/source/core/tool/sharedformula.cxx 
b/sc/source/core/tool/sharedformula.cxx
index fa617df53c7a..7680aac405d4 100644
--- a/sc/source/core/tool/sharedformula.cxx
+++ b/sc/source/core/tool/sharedformula.cxx
@@ -101,14 +101,8 @@ bool SharedFormulaUtil::splitFormulaCellGroup(const 
CellStoreType::position_type
     }
 
     // Apply the lower group object to the lower cells.
-#if DEBUG_COLUMN_STORAGE
-    if (xGroup2->mpTopCell->aPos.Row() + size_t(xGroup2->mnLength) > 
aPos.first->position + aPos.first->size)
-    {
-        cerr << "ScColumn::SplitFormulaCellGroup: Shared formula region goes 
beyond the formula block. Not good." << endl;
-        cerr.flush();
-        abort();
-    }
-#endif
+    assert ((xGroup2 == nullptr || xGroup2->mpTopCell->aPos.Row() + 
size_t(xGroup2->mnLength) <= aPos.first->position + aPos.first->size)
+        && "Shared formula region goes beyond the formula block.");
     sc::formula_block::iterator itEnd = it;
     std::advance(itEnd, nLength2);
     for (; it != itEnd; ++it)
@@ -249,14 +243,8 @@ void SharedFormulaUtil::unshareFormulaCell(const 
CellStoreType::position_type& a
         if (xGroup->mnLength == 2)
         {
             // Group consists of only two cells. Mark the second one 
non-shared.
-#if DEBUG_COLUMN_STORAGE
-            if (aPos.second+1 >= aPos.first->size)
-            {
-                cerr << "ScColumn::UnshareFormulaCell: There is no next 
formula cell but there should be!" << endl;
-                cerr.flush();
-                abort();
-            }
-#endif
+            assert (aPos.second+1 < aPos.first->size
+                && "There is no next formula cell but there should be!");
             ScFormulaCell& rNext = *sc::formula_block::at(*it->data, 
aPos.second+1);
             rNext.SetCellGroup(xNone);
         }
@@ -275,14 +263,7 @@ void SharedFormulaUtil::unshareFormulaCell(const 
CellStoreType::position_type& a
         if (xGroup->mnLength == 2)
         {
             // Mark the top cell non-shared.
-#if DEBUG_COLUMN_STORAGE
-            if (aPos.second == 0)
-            {
-                cerr << "ScColumn::UnshareFormulaCell: There is no previous 
formula cell but there should be!" << endl;
-                cerr.flush();
-                abort();
-            }
-#endif
+            assert(aPos.second != 0 && "There is no previous formula cell but 
there should be!");
             ScFormulaCell& rPrev = *sc::formula_block::at(*it->data, 
aPos.second-1);
             rPrev.SetCellGroup(xNone);
         }
@@ -301,14 +282,7 @@ void SharedFormulaUtil::unshareFormulaCell(const 
CellStoreType::position_type& a
         if (xGroup->mnLength == 1)
         {
             // Make the top cell non-shared.
-#if DEBUG_COLUMN_STORAGE
-            if (aPos.second == 0)
-            {
-                cerr << "ScColumn::UnshareFormulaCell: There is no previous 
formula cell but there should be!" << endl;
-                cerr.flush();
-                abort();
-            }
-#endif
+            assert(aPos.second != 0 && "There is no previous formula cell but 
there should be!");
             ScFormulaCell& rPrev = *sc::formula_block::at(*it->data, 
aPos.second-1);
             rPrev.SetCellGroup(xNone);
         }
@@ -323,14 +297,8 @@ void SharedFormulaUtil::unshareFormulaCell(const 
CellStoreType::position_type& a
             xGroup2->mnLength = nLength2;
             xGroup2->mbInvariant = xGroup->mbInvariant;
             xGroup2->mpCode = xGroup->mpCode->CloneValue();
-#if DEBUG_COLUMN_STORAGE
-            if (xGroup2->mpTopCell->aPos.Row() + size_t(xGroup2->mnLength) > 
it->position + it->size)
-            {
-                cerr << "ScColumn::UnshareFormulaCell: Shared formula region 
goes beyond the formula block. Not good." << endl;
-                cerr.flush();
-                abort();
-            }
-#endif
+            assert(xGroup2->mpTopCell->aPos.Row() + size_t(xGroup2->mnLength) 
<= it->position + it->size
+                && "Shared formula region goes beyond the formula block.");
             sc::formula_block::iterator itCell = 
sc::formula_block::begin(*it->data);
             std::advance(itCell, aPos.second+1);
             sc::formula_block::iterator itCellEnd = itCell;

Reply via email to