sc/source/core/data/documen4.cxx |   19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

New commits:
commit a69a47ffe6d2cfd017d1b53711638305050f8369
Author:     Xisco Fauli <[email protected]>
AuthorDate: Sun Oct 20 22:08:43 2024 +0200
Commit:     Xisco Fauli <[email protected]>
CommitDate: Mon Oct 21 12:48:11 2024 +0200

    tdf#163486: PVS: unused nested loop
    
    Since
    commit 75f0c33a051cb7a0f7665010c4bb8ff015211a3b
    Author: Markus Mohrhard <[email protected]>
    Date:   Tue Jul 5 04:21:41 2011 +0200
    
        change from manual loop to ScMarkData::iterator in calc/source/core
    
    The 'i' counter is not used inside a nested loop. Consider inspecting usage 
of 'k' counter.
    
    Change-Id: Ia7d1aeae86fda108f97c03f6e5ea7724d6542578
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175290
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <[email protected]>
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index c450e698ecba..fbe2970e3a09 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -430,18 +430,19 @@ void ScDocument::InsertTableOp(const ScTabOpParam& 
rParam,  // multiple (repeate
     ScFormulaCell aRefCell( *this, ScAddress( nCol1, nRow1, nTab1 ), 
aForString.makeStringAndClear(),
            formula::FormulaGrammar::GRAM_NATIVE, ScMatrixMode::NONE );
     for( j = nCol1; j <= nCol2; j++ )
+    {
         for( k = nRow1; k <= nRow2; k++ )
-            for (i = 0; i < GetTableCount(); i++)
+        {
+            for (const auto& rTab : rMark)
             {
-                for (const auto& rTab : rMark)
-                {
-                    if (rTab >= nMax)
-                        break;
-                    if( maTabs[rTab] )
-                        maTabs[rTab]->SetFormulaCell(
-                            j, k, new ScFormulaCell(aRefCell, *this, 
ScAddress(j, k, rTab), ScCloneFlags::StartListening));
-                }
+                if (rTab >= nMax)
+                    break;
+                if( maTabs[rTab] )
+                    maTabs[rTab]->SetFormulaCell(
+                        j, k, new ScFormulaCell(aRefCell, *this, ScAddress(j, 
k, rTab), ScCloneFlags::StartListening));
             }
+        }
+    }
 }
 
 namespace {

Reply via email to