summaryrefslogtreecommitdiff
path: root/sc/source/core/tool/interpr1.cxx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-05-05 14:56:52 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-05-11 11:46:30 +0200
commit122e676ce35b34c289cc4c91bb72e25398dc9e12 (patch)
tree0107691e1583baac530bc5962c5cc7ce4cbd6ce8 /sc/source/core/tool/interpr1.cxx
parent4b87523605cf87b548d6eb2604c1d5e84f925038 (diff)
introduce Calc cache for sorted handling of unsorted cells
The idea is that there's a cache for a given range, which keeps a vector of SCROW items, sorted by values of those cells. This allows some specific cases of e.g. COUNTIF to simply use BinarySearch() to find the range that matches and work only with that. This commit implements using this cache for COUNTIF. Change-Id: I5b36b289b4aecb3b8245bbb447fbb299371262e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134120 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc/source/core/tool/interpr1.cxx')
-rw-r--r--sc/source/core/tool/interpr1.cxx15
1 files changed, 12 insertions, 3 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index f71c1941b1a2..ec67766a26d1 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -5747,6 +5747,7 @@ void ScInterpreter::ScCountIf()
ScQueryParam rParam;
rParam.nRow1 = nRow1;
rParam.nRow2 = nRow2;
+ rParam.nTab = nTab1;
ScQueryEntry& rEntry = rParam.GetEntry(0);
ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
@@ -5787,8 +5788,16 @@ void ScInterpreter::ScCountIf()
}
else
{
- ScCountIfCellIteratorDirect aCellIter(mrDoc, mrContext, nTab1, rParam, false);
- fCount += aCellIter.GetCount();
+ if(ScCountIfCellIteratorSortedCache::CanBeUsed(rParam))
+ {
+ ScCountIfCellIteratorSortedCache aCellIter(mrDoc, mrContext, nTab1, rParam, false);
+ fCount += aCellIter.GetCount();
+ }
+ else
+ {
+ ScCountIfCellIteratorDirect aCellIter(mrDoc, mrContext, nTab1, rParam, false);
+ fCount += aCellIter.GetCount();
+ }
}
}
else
@@ -9939,7 +9948,7 @@ utl::SearchParam::SearchType ScInterpreter::DetectSearchType( std::u16string_vie
return utl::SearchParam::SearchType::Normal;
}
-static bool lcl_LookupQuery( ScAddress & o_rResultPos, ScDocument& rDoc, const ScInterpreterContext& rContext,
+static bool lcl_LookupQuery( ScAddress & o_rResultPos, ScDocument& rDoc, ScInterpreterContext& rContext,
const ScQueryParam & rParam, const ScQueryEntry & rEntry )
{
bool bFound = false;