[Libreoffice-commits] core.git: include/comphelper sc/inc sc/source

Michael Meeks michael.meeks at collabora.com
Wed Oct 14 12:37:17 PDT 2015


 include/comphelper/configurationlistener.hxx |    2 +-
 sc/inc/calcconfig.hxx                        |    4 ++++
 sc/source/core/data/formulacell.cxx          |    3 +--
 sc/source/core/inc/interpre.hxx              |    3 ++-
 sc/source/core/tool/calcconfig.cxx           |   16 +++++++++++++++-
 sc/source/core/tool/formulagroup.cxx         |    8 ++++----
 sc/source/core/tool/interpr1.cxx             |    2 +-
 sc/source/core/tool/interpr4.cxx             |   13 ++++++++++---
 sc/source/core/tool/interpr5.cxx             |    3 +--
 9 files changed, 39 insertions(+), 15 deletions(-)

New commits:
commit 866909c1db1c81fc6b64184bbc715766a09e2d4b
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Oct 14 19:28:47 2015 +0100

    Improve performance by using the ScCalcOptions for OpenCL.
    
    Use the new configurationlistener to track the relevant setting.
    
    Change-Id: I9decea55df25f7eb34cd2fef94743d1907360d16
    Reviewed-on: https://gerrit.libreoffice.org/19377
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/include/comphelper/configurationlistener.hxx b/include/comphelper/configurationlistener.hxx
index 2bdb2eec..80194ae 100644
--- a/include/comphelper/configurationlistener.hxx
+++ b/include/comphelper/configurationlistener.hxx
@@ -57,7 +57,7 @@ public:
 
     virtual inline ~ConfigurationListenerProperty();
 
-    uno_type get() { return maValue; }
+    uno_type get() const { return maValue; }
 };
 
 class COMPHELPER_DLLPUBLIC ConfigurationListener :
diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx
index 29337ea..158bc1a 100644
--- a/sc/inc/calcconfig.hxx
+++ b/sc/inc/calcconfig.hxx
@@ -20,6 +20,8 @@
 #include <formula/opcode.hxx>
 #include <rtl/ustring.hxx>
 
+#include <comphelper/configurationlistener.hxx>
+
 // have to match the registry values
 enum ScRecalcOptions
 {
@@ -46,6 +48,8 @@ struct SC_DLLPUBLIC ScCalcConfig
     bool mbEmptyStringAsZero:1;
     bool mbHasStringRefSyntax:1;
 
+    comphelper::ConfigurationListenerProperty<bool> mbOpenCLEnabled;
+
     bool mbOpenCLSubsetOnly:1;
     bool mbOpenCLAutoSelect:1;
     OUString maOpenCLDevice;
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 06f6439..09a06bd 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -60,7 +60,6 @@
 #include <listenerquery.hxx>
 #include <listenerqueryids.hxx>
 #include <grouparealistener.hxx>
-#include <officecfg/Office/Common.hxx>
 
 #include <memory>
 #include <boost/ptr_container/ptr_map.hpp>
@@ -3891,7 +3890,7 @@ bool ScFormulaCell::InterpretFormulaGroup()
             return false;
     }
 
-    if (!officecfg::Office::Common::Misc::UseOpenCL::get())
+    if (!ScInterpreter::GetGlobalConfig().mbOpenCLEnabled.get())
         return false;
 
     // TODO : Disable invariant formula group interpretation for now in order
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 280d9d1..22f9d11 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -146,7 +146,8 @@ public:
     VolatileType GetVolatileType() const { return meVolatileType;}
 
 private:
-    static ScCalcConfig maGlobalConfig;
+    static ScCalcConfig& GetOrCreateGlobalConfig();
+    static ScCalcConfig *mpGlobalConfig;
 
     static ScTokenStack*    pGlobalStack;
     static bool             bGlobalStackInUse;
diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx
index 1f04005..a1ac442 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -20,11 +20,25 @@
 #include "compiler.hxx"
 #include "docsh.hxx"
 
+#include <comphelper/configurationlistener.hxx>
+
+using comphelper::ConfigurationListener;
+
+static rtl::Reference<ConfigurationListener> getMiscListener()
+{
+    static rtl::Reference<ConfigurationListener> xListener;
+    if (!xListener.is())
+        xListener = rtl::Reference<ConfigurationListener>(
+            new ConfigurationListener("/org.openoffice.Office.Common/Misc"));
+    return xListener;
+}
+
 ScCalcConfig::ScCalcConfig() :
     meStringRefAddressSyntax(formula::FormulaGrammar::CONV_UNSPECIFIED),
     meStringConversion(StringConversion::LOCALE),     // old LibreOffice behavior
     mbEmptyStringAsZero(false),
-    mbHasStringRefSyntax(false)
+    mbHasStringRefSyntax(false),
+    mbOpenCLEnabled(getMiscListener(), "UseOpenCL")
 {
     setOpenCLConfigToDefault();
 
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index f3dcd37..659c231 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -477,7 +477,7 @@ FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic()
     {
 #if HAVE_FEATURE_OPENCL
         const ScCalcConfig& rConfig = ScInterpreter::GetGlobalConfig();
-        if (officecfg::Office::Common::Misc::UseOpenCL::get())
+        if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled.get())
             switchOpenCLDevice(rConfig.maOpenCLDevice, rConfig.mbOpenCLAutoSelect);
 #endif
         static bool bAllowSoftwareInterpreter = (getenv("SC_ALLOW_BROKEN_SOFTWARE_INTERPRETER") != NULL);
@@ -503,7 +503,7 @@ void FormulaGroupInterpreter::fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rP
 
 bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect, bool bForceEvaluation)
 {
-    bool bOpenCLEnabled = officecfg::Office::Common::Misc::UseOpenCL::get();
+    bool bOpenCLEnabled = ScInterpreter::GetGlobalConfig().mbOpenCLEnabled.get();
     static bool bAllowSoftwareInterpreter = (getenv("SC_ALLOW_BROKEN_SOFTWARE_INTERPRETER") != NULL);
     if (!bOpenCLEnabled || (bAllowSoftwareInterpreter && rDeviceId == OPENCL_SOFTWARE_DEVICE_CONFIG_NAME))
     {
@@ -526,7 +526,7 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool
     delete msInstance;
     msInstance = NULL;
 
-    if ( officecfg::Office::Common::Misc::UseOpenCL::get() )
+    if ( ScInterpreter::GetGlobalConfig().mbOpenCLEnabled.get() )
     {
         msInstance = new sc::opencl::FormulaGroupInterpreterOpenCL();
         return msInstance != NULL;
@@ -539,7 +539,7 @@ void FormulaGroupInterpreter::getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int3
 {
     rDeviceId = -1;
     rPlatformId = -1;
-    bool bOpenCLEnabled = officecfg::Office::Common::Misc::UseOpenCL::get();
+    bool bOpenCLEnabled = ScInterpreter::GetGlobalConfig().mbOpenCLEnabled.get();
     if(!bOpenCLEnabled)
         return;
 
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index b9cdc1c..e4838e4 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -76,7 +76,7 @@ static const sal_uInt64 n2power48 = SAL_CONST_UINT64( 281474976710656); // 2^48
 IMPL_FIXEDMEMPOOL_NEWDEL( ScTokenStack )
 IMPL_FIXEDMEMPOOL_NEWDEL( ScInterpreter )
 
-ScCalcConfig ScInterpreter::maGlobalConfig;
+ScCalcConfig *ScInterpreter::mpGlobalConfig = NULL;
 ScTokenStack* ScInterpreter::pGlobalStack = NULL;
 bool ScInterpreter::bGlobalStackInUse = false;
 
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index e8a3b1d..bd84fa6 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3503,19 +3503,26 @@ ScInterpreter::~ScInterpreter()
     delete pTokenMatrixMap;
 }
 
+ScCalcConfig& ScInterpreter::GetOrCreateGlobalConfig()
+{
+    if (!mpGlobalConfig)
+        mpGlobalConfig = new ScCalcConfig();
+    return *mpGlobalConfig;
+}
+
 void ScInterpreter::SetGlobalConfig(const ScCalcConfig& rConfig)
 {
-    maGlobalConfig = rConfig;
+    GetOrCreateGlobalConfig() = rConfig;
 }
 
 const ScCalcConfig& ScInterpreter::GetGlobalConfig()
 {
-    return maGlobalConfig;
+    return GetOrCreateGlobalConfig();
 }
 
 void ScInterpreter::MergeCalcConfig()
 {
-    maCalcConfig = maGlobalConfig;
+    maCalcConfig = GetOrCreateGlobalConfig();
     maCalcConfig.MergeDocumentSpecific( pDok->GetCalcConfig());
 }
 
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 0d2fb0a..88cd12d 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -26,7 +26,6 @@
 #endif
 
 #include <unotools/bootstrap.hxx>
-#include <officecfg/Office/Common.hxx>
 #include <svl/zforlist.hxx>
 
 #include "interpre.hxx"
@@ -912,7 +911,7 @@ void ScInterpreter::ScMatInv()
         SCSIZE nC, nR;
         pMat->GetDimensions(nC, nR);
 
-        if (officecfg::Office::Common::Misc::UseOpenCL::get())
+        if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled.get())
         {
             sc::FormulaGroupInterpreter *pInterpreter = sc::FormulaGroupInterpreter::getStatic();
             if (pInterpreter != NULL)


More information about the Libreoffice-commits mailing list