summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-02-14 21:28:06 -0500
committerKohei Yoshida <kyoshida@novell.com>2011-02-14 21:28:06 -0500
commit2545177d36446bc7e84749d1cc5fe77b9308be3e (patch)
tree2a5f74766787a00f7b4d5831a7370aafb1bab817 /sc
parent9d324821f55c7a873f800bca577fcf44443dd9d6 (diff)
Nailed the filtering perf issue for good. (fdo#33720)
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/segmenttree.cxx43
-rw-r--r--sc/source/core/data/table2.cxx168
2 files changed, 106 insertions, 105 deletions
diff --git a/sc/source/core/data/segmenttree.cxx b/sc/source/core/data/segmenttree.cxx
index 16e8d9f4560f..1e32170bdf33 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 41a2d91a11b7..b02789c4afd2 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();
-
- bool bFlagChange = false;
-
- BOOL bWidth = (nRow1==0 && nRow2==MAXROW && pColWidth && pDestTab->pColWidth);
- BOOL bHeight = (nCol1==0 && nCol2==MAXCOL && mpRowHeights && pDestTab->mpRowHeights);
-
- if (bWidth||bHeight)
- {
- pDestTab->IncRecalcLevel();
+ if (!ValidColRow(nCol1, nRow1) || !ValidColRow(nCol2, nRow2))
+ return;
- 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);
- }
+ if (nFlags)
+ for (SCCOL i = nCol1; i <= nCol2; i++)
+ aCol[i].CopyToColumn(nRow1, nRow2, nFlags, bMarked,
+ pDestTab->aCol[i], pMarkData, bAsLink);
- if (bHeight)
- {
- bool bChange = pDestTab->GetRowHeight(nRow1, nRow2) != GetRowHeight(nRow1, nRow2);
+ if (!bColRowFlags) // Spaltenbreiten/Zeilenhoehen/Flags
+ return;
- if (bChange)
- bFlagChange = true;
+ // Charts muessen beim Ein-/Ausblenden angepasst werden
+ ScChartListenerCollection* pCharts = pDestTab->pDocument->GetChartListenerCollection();
- pDestTab->CopyRowHeight(*this, nRow1, nRow2, 0);
- pDestTab->pRowFlags->CopyFrom(*pRowFlags, nRow1, nRow2);
+ bool bFlagChange = false;
- // 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);
+ BOOL bWidth = (nRow1==0 && nRow2==MAXROW && pColWidth && pDestTab->pColWidth);
+ BOOL bHeight = (nCol1==0 && nCol2==MAXCOL && mpRowHeights && pDestTab->mpRowHeights);
- // 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;
+ if (bWidth || bHeight)
+ {
+ pDestTab->IncRecalcLevel();
- pDestTab->SetRowHidden(i, nLastRow, bThisHidden);
+ 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 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
}