[Libreoffice-commits] core.git: Branch 'feature/fixes10' - sc/inc sc/source
Michael Meeks
michael.meeks at collabora.com
Fri Sep 18 04:14:14 PDT 2015
sc/inc/calcconfig.hxx | 5 +++--
sc/source/core/tool/calcconfig.cxx | 18 +++++++++---------
sc/source/core/tool/formulaopt.cxx | 6 +++---
sc/source/core/tool/token.cxx | 4 ++--
sc/source/ui/optdlg/calcoptionsdlg.cxx | 16 ++++++++--------
5 files changed, 25 insertions(+), 24 deletions(-)
New commits:
commit 62cb104dc431692aa2bf9627e792453844c7ec56
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Fri Sep 18 12:11:41 2015 +0300
Tentative performance improvement.
Change-Id: Iec3a6a6869a4546f3d10928470361716d7b10243
diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx
index 18aab21..4cb7222 100644
--- a/sc/inc/calcconfig.hxx
+++ b/sc/inc/calcconfig.hxx
@@ -12,6 +12,7 @@
#include "scdllapi.h"
+#include <memory>
#include <ostream>
#include <set>
@@ -50,9 +51,9 @@ struct SC_DLLPUBLIC ScCalcConfig
OUString maOpenCLDevice;
sal_Int32 mnOpenCLMinimumFormulaGroupSize;
- typedef std::set<OpCode> OpCodeSet;
+ typedef std::shared_ptr<std::set<OpCode>> OpCodeSet;
- OpCodeSet maOpenCLSubsetOpCodes;
+ OpCodeSet mpOpenCLSubsetOpCodes;
ScCalcConfig();
diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx
index d5c1907..12f40a0 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -35,7 +35,7 @@ void ScCalcConfig::setOpenCLConfigToDefault()
{
// Keep in order of opcode value, is that clearest? (Random order,
// at least, would make no sense at all.)
- static const OpCodeSet aDefaultOpenCLSubsetOpCodes {
+ static const std::set<OpCode> aDefaultOpenCLSubsetOpCodes {
ocAdd,
ocSub,
ocMul,
@@ -74,7 +74,7 @@ void ScCalcConfig::setOpenCLConfigToDefault()
mbOpenCLSubsetOnly = true;
mbOpenCLAutoSelect = true;
mnOpenCLMinimumFormulaGroupSize = 100;
- maOpenCLSubsetOpCodes = aDefaultOpenCLSubsetOpCodes;
+ mpOpenCLSubsetOpCodes.reset(new std::set<OpCode>(aDefaultOpenCLSubsetOpCodes));
}
void ScCalcConfig::reset()
@@ -108,7 +108,7 @@ bool ScCalcConfig::operator== (const ScCalcConfig& r) const
mbOpenCLAutoSelect == r.mbOpenCLAutoSelect &&
maOpenCLDevice == r.maOpenCLDevice &&
mnOpenCLMinimumFormulaGroupSize == r.mnOpenCLMinimumFormulaGroupSize &&
- maOpenCLSubsetOpCodes == r.maOpenCLSubsetOpCodes &&
+ *mpOpenCLSubsetOpCodes == *r.mpOpenCLSubsetOpCodes &&
true;
}
@@ -144,7 +144,7 @@ std::ostream& operator<<(std::ostream& rStream, const ScCalcConfig& rConfig)
"OpenCLAutoSelect=" << (rConfig.mbOpenCLAutoSelect?"Y":"N") << ","
"OpenCLDevice='" << rConfig.maOpenCLDevice << "',"
"OpenCLMinimumFormulaGroupSize=" << rConfig.mnOpenCLMinimumFormulaGroupSize << ","
- "OpenCLSubsetOpCodes={" << ScOpCodeSetToSymbolicString(rConfig.maOpenCLSubsetOpCodes) << "},"
+ "OpenCLSubsetOpCodes={" << ScOpCodeSetToSymbolicString(rConfig.mpOpenCLSubsetOpCodes) << "},"
"}";
return rStream;
}
@@ -155,9 +155,9 @@ OUString ScOpCodeSetToSymbolicString(const ScCalcConfig::OpCodeSet& rOpCodes)
formula::FormulaCompiler aCompiler;
formula::FormulaCompiler::OpCodeMapPtr pOpCodeMap(aCompiler.GetOpCodeMap(css::sheet::FormulaLanguage::ENGLISH));
- for (auto i = rOpCodes.cbegin(); i != rOpCodes.cend(); ++i)
+ for (auto i = rOpCodes->cbegin(); i != rOpCodes->cend(); ++i)
{
- if (i != rOpCodes.cbegin())
+ if (i != rOpCodes->cbegin())
result.append(';');
result.append(pOpCodeMap->getSymbol(*i));
}
@@ -167,7 +167,7 @@ OUString ScOpCodeSetToSymbolicString(const ScCalcConfig::OpCodeSet& rOpCodes)
ScCalcConfig::OpCodeSet ScStringToOpCodeSet(const OUString& rOpCodes)
{
- ScCalcConfig::OpCodeSet result;
+ ScCalcConfig::OpCodeSet result(new std::set< OpCode >());
formula::FormulaCompiler aCompiler;
formula::FormulaCompiler::OpCodeMapPtr pOpCodeMap(aCompiler.GetOpCodeMap(css::sheet::FormulaLanguage::ENGLISH));
@@ -184,12 +184,12 @@ ScCalcConfig::OpCodeSet ScStringToOpCodeSet(const OUString& rOpCodes)
OUString element(s.copy(fromIndex, semicolon - fromIndex));
sal_Int32 n = element.toInt32();
if (n > 0 || (n == 0 && element == "0"))
- result.insert(static_cast<OpCode>(n));
+ result->insert(static_cast<OpCode>(n));
else
{
auto opcode(pHashMap->find(element));
if (opcode != pHashMap->end())
- result.insert(static_cast<OpCode>(opcode->second));
+ result->insert(static_cast<OpCode>(opcode->second));
else
SAL_WARN("sc.opencl", "Unrecognized OpCode " << element << " in OpCode set string");
}
diff --git a/sc/source/core/tool/formulaopt.cxx b/sc/source/core/tool/formulaopt.cxx
index 1e0a5f5..78480ed 100644
--- a/sc/source/core/tool/formulaopt.cxx
+++ b/sc/source/core/tool/formulaopt.cxx
@@ -491,9 +491,9 @@ void ScFormulaCfg::UpdateFromProperties( const Sequence<OUString>& aNames )
break;
case SCFORMULAOPT_OPENCL_SUBSET_OPS:
{
- OUString sVal = ScOpCodeSetToSymbolicString(GetCalcConfig().maOpenCLSubsetOpCodes);
+ OUString sVal = ScOpCodeSetToSymbolicString(GetCalcConfig().mpOpenCLSubsetOpCodes);
pValues[nProp] >>= sVal;
- GetCalcConfig().maOpenCLSubsetOpCodes = ScStringToOpCodeSet(sVal);
+ GetCalcConfig().mpOpenCLSubsetOpCodes = ScStringToOpCodeSet(sVal);
}
break;
}
@@ -638,7 +638,7 @@ void ScFormulaCfg::ImplCommit()
break;
case SCFORMULAOPT_OPENCL_SUBSET_OPS:
{
- OUString sVal = ScOpCodeSetToSymbolicString(GetCalcConfig().maOpenCLSubsetOpCodes);
+ OUString sVal = ScOpCodeSetToSymbolicString(GetCalcConfig().mpOpenCLSubsetOpCodes);
pValues[nProp] <<= sVal;
}
break;
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index bb44ca1..e98577b 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1306,7 +1306,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
if (SC_OPCODE_START_FUNCTION <= eOp && eOp < SC_OPCODE_STOP_FUNCTION)
{
- if (ScInterpreter::GetGlobalConfig().mbOpenCLSubsetOnly && ScInterpreter::GetGlobalConfig().maOpenCLSubsetOpCodes.find(eOp) == ScInterpreter::GetGlobalConfig().maOpenCLSubsetOpCodes.end())
+ if (ScInterpreter::GetGlobalConfig().mbOpenCLSubsetOnly && ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->end())
{
meVectorState = FormulaVectorDisabled;
return;
@@ -1547,7 +1547,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
if (eOp >= SC_OPCODE_START_BIN_OP &&
eOp <= SC_OPCODE_STOP_UN_OP &&
ScInterpreter::GetGlobalConfig().mbOpenCLSubsetOnly &&
- ScInterpreter::GetGlobalConfig().maOpenCLSubsetOpCodes.find(eOp) == ScInterpreter::GetGlobalConfig().maOpenCLSubsetOpCodes.end())
+ ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->end())
{
meVectorState = FormulaVectorDisabled;
return;
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx
index 13e9487..eed1362 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.cxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -111,7 +111,7 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(vcl::Window* pParent, const ScCalcConfi
mpSpinButton->SetModifyHdl(LINK(this, ScCalcOptionsDialog, SpinOpenCLMinSizeHdl));
get(mpEditField, "entry");
- mpEditField->SetText(ScOpCodeSetToSymbolicString(maConfig.maOpenCLSubsetOpCodes));
+ mpEditField->SetText(ScOpCodeSetToSymbolicString(maConfig.mpOpenCLSubsetOpCodes));
mpEditField->set_height_request(4 * mpEditField->GetTextHeight());
mpEditField->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl));
@@ -258,7 +258,7 @@ IMPL_LINK_NOARG(ScCalcOptionsDialog, DeviceSelHdl)
IMPL_LINK(ScCalcOptionsDialog, EditModifiedHdl, Edit*, pCtrl)
{
- maConfig.maOpenCLSubsetOpCodes = ScStringToOpCodeSet(pCtrl->GetText());
+ maConfig.mpOpenCLSubsetOpCodes = ScStringToOpCodeSet(pCtrl->GetText());
return 0;
}
@@ -292,7 +292,7 @@ struct OpenCLTester
ScDocShell* mpDocShell;
ScDocument *mpDoc;
bool mbOldAutoCalc;
- ScCalcConfig maOldCalcConfig;
+ ScCalcConfig mpOldCalcConfig;
OpenCLTester() :
mnTestAreas(0)
@@ -311,10 +311,10 @@ struct OpenCLTester
mbOldAutoCalc = mpDoc->GetAutoCalc();
mpDoc->SetAutoCalc(false);
- maOldCalcConfig = ScInterpreter::GetGlobalConfig();
- ScCalcConfig aConfig(maOldCalcConfig);
- aConfig.mnOpenCLMinimumFormulaGroupSize = 20;
- ScInterpreter::SetGlobalConfig(aConfig);
+ mpOldCalcConfig = ScInterpreter::GetGlobalConfig();
+ ScCalcConfig pConfig(mpOldCalcConfig);
+ pConfig.mnOpenCLMinimumFormulaGroupSize = 20;
+ ScInterpreter::SetGlobalConfig(pConfig);
mpDoc->SetString(ScAddress(0,0,0), "Result:");
}
@@ -822,7 +822,7 @@ IMPL_STATIC_LINK(
}));
xTestDocument->mpDoc->CalcAll();
- ScInterpreter::SetGlobalConfig(xTestDocument->maOldCalcConfig);
+ ScInterpreter::SetGlobalConfig(xTestDocument->mpOldCalcConfig);
return 0;
}
More information about the Libreoffice-commits
mailing list