summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-06-14 18:44:02 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-06-15 09:24:17 +0200
commit1cc9f4d972f8a5e1e3f4980942e128dee9a2701c (patch)
tree9eb1aa574bd11b33a41d52f09abf8360a227f023
parent1968563b1dec40f2134a04b1241178ae27b0d6bb (diff)
tdf#126109 calc slow when replacing string to number
retain the column block iterator array during the process, shaves 20% off the time Change-Id: Id492cf142ecc34af6fd236135d87f49b5a630d5e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135855 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/inc/table.hxx3
-rw-r--r--sc/source/core/data/table6.cxx21
2 files changed, 16 insertions, 8 deletions
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 7360b3da6921..da1c0a4d4e98 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -1188,7 +1188,8 @@ private:
const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
SCCOL nLastCol, SCROW nLastRow,
- const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
+ const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc,
+ std::vector< sc::ColumnBlockConstPosition >& blockPos);
bool SearchAll(const SvxSearchItem& rSearchItem, const ScMarkData& rMark,
ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
bool Replace(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index 0ced56900d6d..966b4491c348 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -323,12 +323,14 @@ bool ScTable::Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
GetCellArea( nLastCol, nLastRow);
else
GetLastDataPos(nLastCol, nLastRow);
- return Search(rSearchItem, rCol, rRow, nLastCol, nLastRow, rMark, rUndoStr, pUndoDoc);
+ std::vector< sc::ColumnBlockConstPosition > blockPos;
+ return Search(rSearchItem, rCol, rRow, nLastCol, nLastRow, rMark, rUndoStr, pUndoDoc, blockPos);
}
bool ScTable::Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
SCCOL nLastCol, SCROW nLastRow,
- const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc)
+ const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc,
+ std::vector< sc::ColumnBlockConstPosition >& blockPos)
{
bool bFound = false;
bool bAll = (rSearchItem.GetCommand() == SvxSearchCmd::FIND_ALL)
@@ -339,9 +341,12 @@ bool ScTable::Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
bool bSkipFiltered = !rSearchItem.IsSearchFiltered();
bool bSearchNotes = (rSearchItem.GetCellType() == SvxSearchCellType::NOTE);
// We need to cache sc::ColumnBlockConstPosition per each column.
- std::vector< sc::ColumnBlockConstPosition > blockPos( nLastCol + 1 );
- for( SCCOL i = 0; i <= nLastCol; ++i )
- aCol[ i ].InitBlockPosition( blockPos[ i ] );
+ if (static_cast<SCCOL>(blockPos.size()) != nLastCol + 1)
+ {
+ blockPos.resize( nLastCol + 1 );
+ for( SCCOL i = 0; i <= nLastCol; ++i )
+ aCol[ i ].InitBlockPosition( blockPos[ i ] );
+ }
if (!bAll && rSearchItem.GetBackward())
{
SCROW nLastNonFilteredRow = rDocument.MaxRow() + 1;
@@ -529,9 +534,10 @@ bool ScTable::SearchAll(const SvxSearchItem& rSearchItem, const ScMarkData& rMar
else
GetLastDataPos(nLastCol, nLastRow);
+ std::vector< sc::ColumnBlockConstPosition > blockPos;
do
{
- bFound = Search(rSearchItem, nCol, nRow, nLastCol, nLastRow, rMark, rUndoStr, pUndoDoc);
+ bFound = Search(rSearchItem, nCol, nRow, nLastCol, nLastRow, rMark, rUndoStr, pUndoDoc, blockPos);
if (bFound)
{
bEverFound = true;
@@ -595,10 +601,11 @@ bool ScTable::ReplaceAll(
SvxSearchItem aCopyItem(rSearchItem);
aCopyItem.SetRowDirection(false);
+ std::vector< sc::ColumnBlockConstPosition > blockPos;
bool bEverFound = false;
while (true)
{
- bool bFound = Search(aCopyItem, nCol, nRow, nLastCol, nLastRow, rMark, rUndoStr, pUndoDoc);
+ bool bFound = Search(aCopyItem, nCol, nRow, nLastCol, nLastRow, rMark, rUndoStr, pUndoDoc, blockPos);
if (bFound)
{