summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2019-10-15 08:32:22 +0530
committerDennis Francis <dennis.francis@collabora.com>2019-10-17 08:09:30 +0200
commitc2d8341ee392949274b901abfd44d9645d2e4e36 (patch)
treeb349f0c02b5521359796a9bd6b118a2dbc6d1ee3 /sc/source
parent3c2587a152476cbb0ca4a83138a4c34ec8065b32 (diff)
Cache last used number-format-type in interpreter-context
if in cpu-threaded mode so that we can avoid the unnecessary locked SvNumberFormatter::GetType() calls (Mapping between NF index and NF-type does not change while formula-group-threading is running). Change-Id: I648bc08c885da845f0b09cd57013cc1c23e01a61 Reviewed-on: https://gerrit.libreoffice.org/80848 Tested-by: Jenkins Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/dociter.cxx2
-rw-r--r--sc/source/core/data/document.cxx2
-rw-r--r--sc/source/core/tool/interpr4.cxx2
-rw-r--r--sc/source/core/tool/interpr6.cxx2
-rw-r--r--sc/source/core/tool/interpretercontext.cxx19
5 files changed, 23 insertions, 4 deletions
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 70362f342b21..3c8e369a575a 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -273,7 +273,7 @@ void ScValueIterator::GetCurNumFmtInfo( const ScInterpreterContext& rContext, Sv
SCROW nCurRow = GetRow();
const ScColumn* pCol = &(pDoc->maTabs[mnTab])->aCol[mnCol];
nNumFmtIndex = pCol->GetNumberFormat(rContext, nCurRow);
- nNumFmtType = rContext.GetFormatTable()->GetType( nNumFmtIndex );
+ nNumFmtType = rContext.GetNumberFormatType( nNumFmtIndex );
bNumValid = true;
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index cc961b20b1a4..82224b23ecb3 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3692,7 +3692,7 @@ void ScDocument::GetNumberFormatInfo( const ScInterpreterContext& rContext, SvNu
if ( nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
{
nIndex = maTabs[nTab]->GetNumberFormat( rContext, rPos );
- nType = rContext.GetFormatTable()->GetType( nIndex );
+ nType = rContext.GetNumberFormatType( nIndex );
}
else
{
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 544a9ab11d0a..fc419d4a5935 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -223,7 +223,7 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, ScRefCellValue&
{
fValue = rCell.mfValue;
nCurFmtIndex = pDok->GetNumberFormat( mrContext, rPos );
- nCurFmtType = pFormatter->GetType( nCurFmtIndex );
+ nCurFmtType = mrContext.GetNumberFormatType( nCurFmtIndex );
if ( bCalcAsShown && fValue != 0.0 )
fValue = pDok->RoundValueAsShown( fValue, nCurFmtIndex, &mrContext );
}
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 3a77be206acc..c2655fceb3d7 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -850,7 +850,7 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero )
nFuncFmtIndex = aAction.getNumberFormat();
}
- nFuncFmtType = mrContext.GetFormatTable()->GetType( nFuncFmtIndex );
+ nFuncFmtType = mrContext.GetNumberFormatType( nFuncFmtIndex );
}
else
{
diff --git a/sc/source/core/tool/interpretercontext.cxx b/sc/source/core/tool/interpretercontext.cxx
index b997effe13c4..77d2feadce6a 100644
--- a/sc/source/core/tool/interpretercontext.cxx
+++ b/sc/source/core/tool/interpretercontext.cxx
@@ -18,6 +18,7 @@
*/
#include <interpretercontext.hxx>
+#include <svl/zforlist.hxx>
#include <document.hxx>
#include <formula/token.hxx>
@@ -68,6 +69,24 @@ void ScInterpreterContext::ClearLookupCache()
mScLookupCache = nullptr;
}
+SvNumFormatType ScInterpreterContext::GetNumberFormatType(sal_uInt32 nFIndex) const
+{
+ if (!mpDoc->IsThreadedGroupCalcInProgress())
+ {
+ return mpFormatter->GetType(nFIndex);
+ }
+
+ if (maNFTypeCache.bIsValid && maNFTypeCache.nIndex == nFIndex)
+ {
+ return maNFTypeCache.eType;
+ }
+
+ maNFTypeCache.nIndex = nFIndex;
+ maNFTypeCache.eType = mpFormatter->GetType(nFIndex);
+ maNFTypeCache.bIsValid = true;
+ return maNFTypeCache.eType;
+}
+
/* ScInterpreterContextPool */
// Threaded version