summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-09-18 12:11:41 +0300
committerTor Lillqvist <tml@collabora.com>2015-09-18 15:04:34 +0300
commit1fa2398967d85abdd23fb233494d411276853760 (patch)
tree36e67a33f229dbc40f596cbdf68b14f099eeb37a
parentec76524221c146635e0046f567ddd31e1e28be3c (diff)
Tentative performance improvement.
Change-Id: Iec3a6a6869a4546f3d10928470361716d7b10243
-rw-r--r--sc/inc/calcconfig.hxx5
-rw-r--r--sc/source/core/tool/calcconfig.cxx18
-rw-r--r--sc/source/core/tool/formulaopt.cxx6
-rw-r--r--sc/source/core/tool/token.cxx4
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.cxx16
5 files changed, 25 insertions, 24 deletions
diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx
index e271421b6884..1d28a60f93a7 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 d5c190732957..12f40a002c33 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 3e35c626a66c..7bb264bace36 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 8a67152008de..439134fae419 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1315,7 +1315,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;
@@ -1556,7 +1556,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 c1b02b2d4898..d9965ebf5f57 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));
@@ -252,7 +252,7 @@ IMPL_LINK_NOARG_TYPED(ScCalcOptionsDialog, DeviceSelHdl, SvTreeListBox*, void)
IMPL_LINK(ScCalcOptionsDialog, EditModifiedHdl, Edit*, pCtrl)
{
- maConfig.maOpenCLSubsetOpCodes = ScStringToOpCodeSet(pCtrl->GetText());
+ maConfig.mpOpenCLSubsetOpCodes = ScStringToOpCodeSet(pCtrl->GetText());
return 0;
}
@@ -286,7 +286,7 @@ struct OpenCLTester
ScDocShell* mpDocShell;
ScDocument *mpDoc;
bool mbOldAutoCalc;
- ScCalcConfig maOldCalcConfig;
+ ScCalcConfig mpOldCalcConfig;
OpenCLTester() :
mnTestAreas(0)
@@ -305,10 +305,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:");
}
@@ -815,7 +815,7 @@ IMPL_STATIC_LINK_TYPED(ScCalcOptionsDialog, TestClickHdl, Button*, pButton, void
}));
xTestDocument->mpDoc->CalcAll();
- ScInterpreter::SetGlobalConfig(xTestDocument->maOldCalcConfig);
+ ScInterpreter::SetGlobalConfig(xTestDocument->mpOldCalcConfig);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */