sc/inc/interpretercontext.hxx              |    4 ++--
 sc/source/core/data/documen2.cxx           |    2 +-
 sc/source/core/tool/interpretercontext.cxx |   12 ++++++++----
 3 files changed, 11 insertions(+), 7 deletions(-)

New commits:
commit dffeb48f25123b16e60aed5aa4abaeefa92f83a1
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Sun Nov 13 01:41:11 2022 +0100
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Sun Nov 13 16:26:56 2022 +0100

    Clear only lookup caches of calling document
    
    It is the same for always reused interpreter context slots but
    does not hurt and prepares for when more than one document is to
    be cached.
    
    Change-Id: Icc8532080f618b9a50627a6e551dfb28803d3c34
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142643
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/sc/inc/interpretercontext.hxx b/sc/inc/interpretercontext.hxx
index 4ecb1ed9de1a..39d528cb6ca9 100644
--- a/sc/inc/interpretercontext.hxx
+++ b/sc/inc/interpretercontext.hxx
@@ -82,7 +82,7 @@ private:
     void ResetTokens();
     void SetDocAndFormatter(const ScDocument& rDoc, SvNumberFormatter* 
pFormatter);
     void Cleanup();
-    void ClearLookupCache();
+    void ClearLookupCache(const ScDocument* pDoc);
     void initFormatTable();
     SvNumberFormatter* mpFormatter;
     mutable NFIndexAndFmtType maNFTypeCache;
@@ -135,7 +135,7 @@ class ScInterpreterContextPool
 
 public:
     // Only to be used to clear lookup cache in all pool elements
-    static void ClearLookupCaches();
+    static void ClearLookupCaches(const ScDocument* pDoc);
 };
 
 class ScThreadedInterpreterContextGetterGuard
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index f784d510fe6c..af4629d7aef3 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1280,7 +1280,7 @@ void ScDocument::ClearLookupCaches()
     GetNonThreadedContext().mxScLookupCache.reset();
     mxScSortedRangeCache->aCacheMap.clear();
     // Clear lookup cache in all interpreter-contexts in the 
(threaded/non-threaded) pools.
-    ScInterpreterContextPool::ClearLookupCaches();
+    ScInterpreterContextPool::ClearLookupCaches(this);
 }
 
 bool ScDocument::IsCellInChangeTrack(const ScAddress &cell,Color 
*pColCellBorder)
diff --git a/sc/source/core/tool/interpretercontext.cxx 
b/sc/source/core/tool/interpretercontext.cxx
index e66a8b977446..deb6f6d0ed5b 100644
--- a/sc/source/core/tool/interpretercontext.cxx
+++ b/sc/source/core/tool/interpretercontext.cxx
@@ -74,7 +74,11 @@ void ScInterpreterContext::Cleanup()
     ResetTokens();
 }
 
-void ScInterpreterContext::ClearLookupCache() { mxScLookupCache.reset(); }
+void ScInterpreterContext::ClearLookupCache(const ScDocument* pDoc)
+{
+    if (pDoc == mpDoc)
+        mxScLookupCache.reset();
+}
 
 SvNumFormatType ScInterpreterContext::GetNumberFormatType(sal_uInt32 nFIndex) 
const
 {
@@ -161,12 +165,12 @@ void ScInterpreterContextPool::ReturnToPool()
 }
 
 // static
-void ScInterpreterContextPool::ClearLookupCaches()
+void ScInterpreterContextPool::ClearLookupCaches(const ScDocument* pDoc)
 {
     for (auto& rPtr : aThreadedInterpreterPool.maPool)
-        rPtr->ClearLookupCache();
+        rPtr->ClearLookupCache(pDoc);
     for (auto& rPtr : aNonThreadedInterpreterPool.maPool)
-        rPtr->ClearLookupCache();
+        rPtr->ClearLookupCache(pDoc);
 }
 
 /* ScThreadedInterpreterContextGetterGuard */

Reply via email to