desktop/source/app/opencl.cxx        |    2 +-
 include/opencl/openclwrapper.hxx     |    4 ++--
 opencl/source/openclwrapper.cxx      |    6 ++----
 sc/inc/formulagroup.hxx              |    2 +-
 sc/qa/unit/opencl-test.cxx           |    2 +-
 sc/source/core/tool/formulagroup.cxx |    6 +++---
 sc/source/ui/unoobj/docuno.cxx       |    4 ++--
 7 files changed, 12 insertions(+), 14 deletions(-)

New commits:
commit 4140154fe76ab627ad142ecb9db62d304eae146c
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Mon Jul 4 21:02:16 2022 +0100
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Wed Jul 6 10:29:45 2022 +0200

    opencl: no need for unhelpful nullptr OUString * case.
    
    Change-Id: I0b3cad2247706901e1a6b9c3df7fbbc9f23ff987
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136816
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>

diff --git a/desktop/source/app/opencl.cxx b/desktop/source/app/opencl.cxx
index fb5c3723ed8b..dc3fb67f214b 100644
--- a/desktop/source/app/opencl.cxx
+++ b/desktop/source/app/opencl.cxx
@@ -198,7 +198,7 @@ void Desktop::CheckOpenCLCompute(const Reference< XDesktop2 
> &xDesktop)
     OUString aDevice = 
officecfg::Office::Calc::Formula::Calculation::OpenCLDevice::get();
     OUString aSelectedCLDeviceVersionID;
     if (!openclwrapper::switchOpenCLDevice(
-            &aDevice,
+            aDevice,
             
officecfg::Office::Calc::Formula::Calculation::OpenCLAutoSelect::get(),
             false /* bForceEvaluation */,
             aSelectedCLDeviceVersionID))
diff --git a/include/opencl/openclwrapper.hxx b/include/opencl/openclwrapper.hxx
index 81138ced24e8..bfaa49e99b26 100644
--- a/include/opencl/openclwrapper.hxx
+++ b/include/opencl/openclwrapper.hxx
@@ -65,13 +65,13 @@ OPENCL_DLLPUBLIC const std::vector<OpenCLPlatformInfo>& 
fillOpenCLInfo();
 /**
  * Used to set or switch between OpenCL devices.
  *
- * @param pDeviceId the id of the opencl device of type cl_device_id, NULL 
means use software calculation
+ * @param aDeviceId the id of the opencl device of type cl_device_id, "" means 
use software calculation
  * @param bAutoSelect use the algorithm to select the best OpenCL device
  * @param rOutSelectedDeviceVersionIDString returns the selected device's 
version string.
  *
  * @return returns true if there is a valid opencl device that has been set up
  */
-OPENCL_DLLPUBLIC bool switchOpenCLDevice(const OUString* pDeviceId, bool 
bAutoSelect,
+OPENCL_DLLPUBLIC bool switchOpenCLDevice(std::u16string_view aDevice, bool 
bAutoSelect,
                                          bool bForceEvaluation,
                                          OUString& 
rOutSelectedDeviceVersionIDString);
 
diff --git a/opencl/source/openclwrapper.cxx b/opencl/source/openclwrapper.cxx
index f6d1242baa3d..dd1850976c08 100644
--- a/opencl/source/openclwrapper.cxx
+++ b/opencl/source/openclwrapper.cxx
@@ -760,14 +760,12 @@ bool canUseOpenCL()
     return !getenv("SAL_DISABLE_OPENCL") && 
officecfg::Office::Common::Misc::UseOpenCL::get();
 }
 
-bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool 
bForceEvaluation, OUString& rOutSelectedDeviceVersionIDString)
+bool switchOpenCLDevice(std::u16string_view aDevice, bool bAutoSelect, bool 
bForceEvaluation, OUString& rOutSelectedDeviceVersionIDString)
 {
     if (!canUseOpenCL() || fillOpenCLInfo().empty())
         return false;
 
-    cl_device_id pDeviceId = nullptr;
-    if(pDevice)
-        pDeviceId = findDeviceIdByDeviceString(*pDevice, fillOpenCLInfo());
+    cl_device_id pDeviceId = findDeviceIdByDeviceString(aDevice, 
fillOpenCLInfo());
 
     if(!pDeviceId || bAutoSelect)
     {
diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index 88e54820ed3f..95b354f794b4 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -135,7 +135,7 @@ public:
     static FormulaGroupInterpreter *getStatic();
 #if HAVE_FEATURE_OPENCL
     static void fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rPlatforms);
-    static bool switchOpenCLDevice(const OUString& rDeviceId, bool 
bAutoSelect, bool bForceEvaluation = false);
+    static bool switchOpenCLDevice(std::u16string_view rDeviceId, bool 
bAutoSelect, bool bForceEvaluation = false);
     // This is intended to be called from opencl-test.cxx only
     static void enableOpenCL_UnitTestsOnly();
     static void disableOpenCL_UnitTestsOnly();
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 3b1132629ce0..7260a9221962 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -527,7 +527,7 @@ bool ScOpenCLTest::initTestEnv(std::u16string_view 
fileName, sal_Int32 nFormat,
 bool ScOpenCLTest::detectOpenCLDevice()
 {
     sc::FormulaGroupInterpreter::enableOpenCL_UnitTestsOnly();
-    return sc::FormulaGroupInterpreter::switchOpenCLDevice(OUString(),true);
+    return sc::FormulaGroupInterpreter::switchOpenCLDevice(u"",true);
 }
 
 void ScOpenCLTest::enableOpenCL()
diff --git a/sc/source/core/tool/formulagroup.cxx 
b/sc/source/core/tool/formulagroup.cxx
index c7ac689f25f3..7b1965c2eb79 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -178,10 +178,10 @@ void 
FormulaGroupInterpreter::fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rP
     rPlatforms.assign(rPlatformsFromWrapper.begin(), 
rPlatformsFromWrapper.end());
 }
 
-bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, 
bool bAutoSelect, bool bForceEvaluation)
+bool FormulaGroupInterpreter::switchOpenCLDevice(std::u16string_view 
rDeviceId, bool bAutoSelect, bool bForceEvaluation)
 {
     bool bOpenCLEnabled = ScCalcConfig::isOpenCLEnabled();
-    if (!bOpenCLEnabled || (rDeviceId == OPENCL_SOFTWARE_DEVICE_CONFIG_NAME))
+    if (!bOpenCLEnabled || (rDeviceId == u"" 
OPENCL_SOFTWARE_DEVICE_CONFIG_NAME))
     {
         delete msInstance;
         msInstance = nullptr;
@@ -189,7 +189,7 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const 
OUString& rDeviceId, bool
     }
 
     OUString aSelectedCLDeviceVersionID;
-    bool bSuccess = openclwrapper::switchOpenCLDevice(&rDeviceId, bAutoSelect, 
bForceEvaluation, aSelectedCLDeviceVersionID);
+    bool bSuccess = openclwrapper::switchOpenCLDevice(rDeviceId, bAutoSelect, 
bForceEvaluation, aSelectedCLDeviceVersionID);
 
     if (!bSuccess)
         return false;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 2f27948d0fe2..70207977aae6 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -3347,7 +3347,7 @@ void ScModelObj::enableOpenCL(sal_Bool bEnable)
     ScInterpreter::SetGlobalConfig(aConfig);
 
 #if HAVE_FEATURE_OPENCL
-    sc::FormulaGroupInterpreter::switchOpenCLDevice(OUString(), true);
+    sc::FormulaGroupInterpreter::switchOpenCLDevice(u"", true);
 #endif
 
     ScDocument* pDoc = GetDocument();
@@ -3366,7 +3366,7 @@ void ScModelObj::enableAutomaticDeviceSelection(sal_Bool 
bForce)
 #if !HAVE_FEATURE_OPENCL
     (void) bForce;
 #else
-    sc::FormulaGroupInterpreter::switchOpenCLDevice(OUString(), true, bForce);
+    sc::FormulaGroupInterpreter::switchOpenCLDevice(u"", true, bForce);
 #endif
 }
 

Reply via email to