[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Feb 14 18:31:12 PST 2011


 sc/source/core/data/segmenttree.cxx |   43 +++++----
 sc/source/core/data/table2.cxx      |  168 ++++++++++++++++--------------------
 2 files changed, 106 insertions(+), 105 deletions(-)

New commits:
commit e04a42c7dea497c0a4e6159ed5c33910c16a51ca
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Feb 14 21:28:06 2011 -0500

    Nailed the filtering perf issue for good. (fdo#33720)

diff --git a/sc/source/core/data/segmenttree.cxx b/sc/source/core/data/segmenttree.cxx
index b4d5a17..22ec42c 100644
--- a/sc/source/core/data/segmenttree.cxx
+++ b/sc/source/core/data/segmenttree.cxx
@@ -61,6 +61,7 @@ public:
     ValueType getValue(SCCOLROW nPos);
     ExtValueType getSumValue(SCCOLROW nPos1, SCCOLROW nPos2);
     bool getRangeData(SCCOLROW nPos, RangeData& rData);
+    bool getRangeDataLeaf(SCCOLROW nPos, RangeData& rData);
     void removeSegment(SCCOLROW nPos1, SCCOLROW nPos2);
     void insertSegment(SCCOLROW nPos, SCCOLROW nSize, bool bSkipStartBoundary);
 
@@ -172,28 +173,38 @@ ScFlatSegmentsImpl<_ValueType, _ExtValueType>::getSumValue(SCCOLROW nPos1, SCCOL
 template<typename _ValueType, typename _ExtValueType>
 bool ScFlatSegmentsImpl<_ValueType, _ExtValueType>::getRangeData(SCCOLROW nPos, RangeData& rData)
 {
+    if (!mbTreeSearchEnabled)
+        return getRangeDataLeaf(nPos, rData);
+
     ValueType nValue;
     SCCOLROW nPos1, nPos2;
 
-    if (mbTreeSearchEnabled)
-    {
-        if (!maSegments.is_tree_valid())
-            maSegments.build_tree();
+    if (!maSegments.is_tree_valid())
+        maSegments.build_tree();
 
-        if (!maSegments.search_tree(nPos, nValue, &nPos1, &nPos2))
-            return false;
-    }
-    else
-    {
-        // Conduct leaf-node only search.  Faster when searching between range insertion.
-        ::std::pair<typename fst_type::const_iterator, bool> ret =
-            maSegments.search(maItr, nPos, nValue, &nPos1, &nPos2);
+    if (!maSegments.search_tree(nPos, nValue, &nPos1, &nPos2))
+        return false;
 
-        if (!ret.second)
-            return false;
+    rData.mnPos1 = nPos1;
+    rData.mnPos2 = nPos2-1; // end point is not inclusive.
+    rData.mnValue = nValue;
+    return true;
+}
 
-        maItr = ret.first;
-    }
+template<typename _ValueType, typename _ExtValueType>
+bool ScFlatSegmentsImpl<_ValueType, _ExtValueType>::getRangeDataLeaf(SCCOLROW nPos, RangeData& rData)
+{
+    ValueType nValue;
+    SCCOLROW nPos1, nPos2;
+
+    // Conduct leaf-node only search.  Faster when searching between range insertion.
+    ::std::pair<typename fst_type::const_iterator, bool> ret =
+        maSegments.search(maItr, nPos, nValue, &nPos1, &nPos2);
+
+    if (!ret.second)
+        return false;
+
+    maItr = ret.first;
 
     rData.mnPos1 = nPos1;
     rData.mnPos2 = nPos2-1; // end point is not inclusive.
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 572fb76..a881598 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -61,8 +61,6 @@
 #include "globstr.hrc"
 #include "segmenttree.hxx"
 
-#include <math.h>
-
 // STATIC DATA -----------------------------------------------------------
 
 
@@ -722,108 +720,100 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                             const ScMarkData* pMarkData,
                             BOOL bAsLink, BOOL bColRowFlags)
 {
-    if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))
-    {
-        if (nFlags)
-            for (SCCOL i = nCol1; i <= nCol2; i++)
-                aCol[i].CopyToColumn(nRow1, nRow2, nFlags, bMarked,
-                                pDestTab->aCol[i], pMarkData, bAsLink);
-
-        if (bColRowFlags)		// Spaltenbreiten/Zeilenhoehen/Flags
-        {
-            //	Charts muessen beim Ein-/Ausblenden angepasst werden
-            ScChartListenerCollection* pCharts = pDestTab->pDocument->GetChartListenerCollection();
+    if (!ValidColRow(nCol1, nRow1) || !ValidColRow(nCol2, nRow2))
+        return;
 
-            bool bFlagChange = false;
+    if (nFlags)
+        for (SCCOL i = nCol1; i <= nCol2; i++)
+            aCol[i].CopyToColumn(nRow1, nRow2, nFlags, bMarked,
+                                pDestTab->aCol[i], pMarkData, bAsLink);
 
-            BOOL bWidth  = (nRow1==0 && nRow2==MAXROW && pColWidth && pDestTab->pColWidth);
-            BOOL bHeight = (nCol1==0 && nCol2==MAXCOL && mpRowHeights && pDestTab->mpRowHeights);
+    if (!bColRowFlags)		// Spaltenbreiten/Zeilenhoehen/Flags
+        return;
 
-            if (bWidth||bHeight)
-            {
-                pDestTab->IncRecalcLevel();
+    //	Charts muessen beim Ein-/Ausblenden angepasst werden
+    ScChartListenerCollection* pCharts = pDestTab->pDocument->GetChartListenerCollection();
 
-                if (bWidth)
-                {
-                    for (SCCOL i=nCol1; i<=nCol2; i++)
-                    {
-                        bool bThisHidden = ColHidden(i);
-                        bool bHiddenChange = (pDestTab->ColHidden(i) != bThisHidden);
-                        bool bChange = bHiddenChange || (pDestTab->pColWidth[i] != pColWidth[i]);
-                        pDestTab->pColWidth[i] = pColWidth[i];
-                        pDestTab->pColFlags[i] = pColFlags[i];
-                        pDestTab->SetColHidden(i, i, bThisHidden);
-                        //!	Aenderungen zusammenfassen?
-                        if (bHiddenChange && pCharts) 
-                            pCharts->SetRangeDirty(ScRange( i, 0, nTab, i, MAXROW, nTab ));
-
-                        if (bChange)
-                            bFlagChange = true;
-                    }
-                    pDestTab->SetColManualBreaks( maColManualBreaks);
-                }
+    bool bFlagChange = false;
 
-                if (bHeight)
-                {
-                    bool bChange = pDestTab->GetRowHeight(nRow1, nRow2) != GetRowHeight(nRow1, nRow2);
+    BOOL bWidth  = (nRow1==0 && nRow2==MAXROW && pColWidth && pDestTab->pColWidth);
+    BOOL bHeight = (nCol1==0 && nCol2==MAXCOL && mpRowHeights && pDestTab->mpRowHeights);
 
-                    if (bChange)
-                        bFlagChange = true;
+    if (bWidth || bHeight)
+    {
+        pDestTab->IncRecalcLevel();
 
-                    pDestTab->CopyRowHeight(*this, nRow1, nRow2, 0);
-                    pDestTab->pRowFlags->CopyFrom(*pRowFlags, nRow1, nRow2);
+        if (bWidth)
+        {
+            for (SCCOL i = nCol1; i <= nCol2; ++i)
+            {
+                bool bThisHidden = ColHidden(i);
+                bool bHiddenChange = (pDestTab->ColHidden(i) != bThisHidden);
+                bool bChange = bHiddenChange || (pDestTab->pColWidth[i] != pColWidth[i]);
+                pDestTab->pColWidth[i] = pColWidth[i];
+                pDestTab->pColFlags[i] = pColFlags[i];
+                pDestTab->SetColHidden(i, i, bThisHidden);
+                //!	Aenderungen zusammenfassen?
+                if (bHiddenChange && pCharts)
+                    pCharts->SetRangeDirty(ScRange( i, 0, nTab, i, MAXROW, nTab ));
+
+                if (bChange)
+                    bFlagChange = true;
+            }
+            pDestTab->SetColManualBreaks( maColManualBreaks);
+        }
 
-                    // Hidden flags.
-                    for (SCROW i = nRow1; i <= nRow2; ++i)
-                    {
-                        SCROW nThisLastRow, nDestLastRow;
-                        bool bThisHidden = RowHidden(i, NULL, &nThisLastRow);
-                        bool bDestHidden = pDestTab->RowHidden(i, NULL, &nDestLastRow);
-
-                        // If the segment sizes differ, we take the shorter segment of the two.
-                        SCROW nLastRow = ::std::min(nThisLastRow, nDestLastRow);
-                        if (nLastRow >= nRow2)
-                            // the last row shouldn't exceed the upper bound the caller specified.
-                            nLastRow = nRow2;
-    
-                        pDestTab->SetRowHidden(i, nLastRow, bThisHidden);
-
-                        bool bThisHiddenChange = (bThisHidden != bDestHidden);
-                        if (bThisHiddenChange && pCharts)
-                        {
-                            // Hidden flags differ.
-                            pCharts->SetRangeDirty(ScRange(0, i, nTab, MAXCOL, nLastRow, nTab));
-                        }
+        if (bHeight)
+        {
+            bool bChange = pDestTab->GetRowHeight(nRow1, nRow2) != GetRowHeight(nRow1, nRow2);
 
-                        if (bThisHiddenChange)
-                            bFlagChange = true;
+            if (bChange)
+                bFlagChange = true;
 
-                        // Jump to the last row of the identical flag segment.
-                        i = nLastRow;
-                    }
+            pDestTab->CopyRowHeight(*this, nRow1, nRow2, 0);
+            pDestTab->pRowFlags->CopyFrom(*pRowFlags, nRow1, nRow2);
 
-                    // Filtered flags.
-                    for (SCROW i = nRow1; i <= nRow2; ++i)
-                    {
-                        SCROW nLastRow;
-                        bool bFiltered = RowFiltered(i, NULL, &nLastRow);
-                        if (nLastRow >= nRow2)
-                            // the last row shouldn't exceed the upper bound the caller specified.
-                            nLastRow = nRow2;
-                        pDestTab->SetRowFiltered(i, nLastRow, bFiltered);
-                        i = nLastRow;
-                    }
-                    pDestTab->SetRowManualBreaks( maRowManualBreaks);
-                }
-                pDestTab->DecRecalcLevel();
+            // Hidden flags.
+            for (SCROW i = nRow1; i <= nRow2; ++i)
+            {
+                SCROW nLastRow;
+                bool bHidden = RowHidden(i, NULL, &nLastRow);
+                if (nLastRow >= nRow2)
+                    // the last row shouldn't exceed the upper bound the caller specified.
+                    nLastRow = nRow2;
+
+                bool bHiddenChanged = pDestTab->SetRowHidden(i, nLastRow, bHidden);
+                if (bHiddenChanged && pCharts)
+                    // Hidden flags differ.
+                    pCharts->SetRangeDirty(ScRange(0, i, nTab, MAXCOL, nLastRow, nTab));
+
+                if (bHiddenChanged)
+                    bFlagChange = true;
+
+                // Jump to the last row of the identical flag segment.
+                i = nLastRow;
             }
 
-            if (bFlagChange)
-                pDestTab->InvalidatePageBreaks();
-
-            pDestTab->SetOutlineTable( pOutlineTable );		// auch nur wenn bColRowFlags
+            // Filtered flags.
+            for (SCROW i = nRow1; i <= nRow2; ++i)
+            {
+                SCROW nLastRow;
+                bool bFiltered = RowFiltered(i, NULL, &nLastRow);
+                if (nLastRow >= nRow2)
+                    // the last row shouldn't exceed the upper bound the caller specified.
+                    nLastRow = nRow2;
+                pDestTab->SetRowFiltered(i, nLastRow, bFiltered);
+                i = nLastRow;
+            }
+            pDestTab->SetRowManualBreaks( maRowManualBreaks);
         }
+        pDestTab->DecRecalcLevel();
     }
+
+    if (bFlagChange)
+        pDestTab->InvalidatePageBreaks();
+
+    pDestTab->SetOutlineTable( pOutlineTable );		// auch nur wenn bColRowFlags
 }
 
 


More information about the Libreoffice-commits mailing list