[PATCH] Optimization in for loop condition part

Karthikeyan Krishnamurthi (via Code Review) gerrit at gerrit.libreoffice.org
Mon Jan 7 02:54:38 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1560

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/60/1560/1

Optimization in for loop condition part

Change-Id: Ia9a52598e9c295fee8be040530ca232fddbd14c3
---
M svx/source/table/tablemodel.cxx
1 file changed, 4 insertions(+), 2 deletions(-)



diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx
index 46b1c9a..34778d3 100644
--- a/svx/source/table/tablemodel.cxx
+++ b/svx/source/table/tablemodel.cxx
@@ -1028,10 +1028,11 @@
     if( !maRows.empty() && !maColumns.empty() )
     {
         sal_Int32 nCol = getColumnCountImpl() - 1;
+        sal_Int32 nRows = getRowCountImpl();
         while( nCol > 0 )
         {
             bool bEmpty = true;
-            for( sal_Int32 nRow = 0; (nRow < getRowCountImpl()) && bEmpty; nRow++ )
+            for( sal_Int32 nRow = 0; (nRow < nRows) && bEmpty; nRow++ )
             {
                 Reference< XMergeableCell > xCell( getCellByPosition( nCol, nRow ), UNO_QUERY );
                 if( xCell.is() && !xCell->isMerged() )
@@ -1065,10 +1066,11 @@
         }
 
         sal_Int32 nRow = getRowCountImpl() - 1;
+        sal_Int32 nCols = getColumnCountImpl();
         while( nRow > 0 )
         {
             bool bEmpty = true;
-            for( nCol = 0; (nCol < getColumnCountImpl()) && bEmpty; nCol++ )
+            for( nCol = 0; (nCol < nCols) && bEmpty; nCol++ )
             {
                 Reference< XMergeableCell > xCell( getCellByPosition( nCol, nRow ), UNO_QUERY );
                 if( xCell.is() && !xCell->isMerged() )

-- 
To view, visit https://gerrit.libreoffice.org/1560
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia9a52598e9c295fee8be040530ca232fddbd14c3
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Karthikeyan Krishnamurthi <karthikeyan at kacst.edu.sa>



More information about the LibreOffice mailing list