summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-11-12 14:43:41 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-11-12 18:51:38 -0500
commit177c0adede9ba4b34aa3f4a80cf7021e327c9d20 (patch)
treec5516dcffacb1f3c0cc087e1ef5671b9ff6f23c7 /sc/source
parenta621bdb0aad19a3a5ee4ff7089fca7cfe0ba1467 (diff)
Reduce the amount of RPM token generation.
Change-Id: I03941690114b17d8ab63cfb9b1b23a2ff1741b10
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/formulacell.cxx6
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx12
-rw-r--r--sc/source/core/tool/formulagroup.cxx10
-rw-r--r--sc/source/filter/oox/formulabuffer.cxx4
4 files changed, 10 insertions, 22 deletions
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 5e92efa27a5b..07f865681f66 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -3468,6 +3468,7 @@ public:
bool convert(ScTokenArray& rCode)
{
+#if 0
{ // debug to start with:
ScCompiler aComp( &mrDoc, mrPos, rCode);
aComp.SetGrammar(formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1);
@@ -3475,6 +3476,7 @@ public:
aComp.CreateStringFromTokenArray(aAsString);
SAL_DEBUG("interpret formula: " << aAsString.makeStringAndClear());
}
+#endif
rCode.Reset();
for (const formula::FormulaToken* p = rCode.First(); p; p = rCode.Next())
@@ -3614,6 +3616,10 @@ public:
}
}
+ ScCompiler aComp(&mrDoc, mrPos, mrGroupTokens);
+ aComp.SetGrammar(mrDoc.GetGrammar());
+ aComp.CompileTokenArray(); // Regenerate RPN tokens.
+
return true;
}
};
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 60b126c3c530..c6ae8e8e235a 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1416,20 +1416,9 @@ public:
virtual ScMatrixRef inverseMatrix( const ScMatrix& rMat );
virtual bool interpret( ScDocument& rDoc, const ScAddress& rTopPos,
const ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode );
- void generateRPNCode(ScDocument& rDoc,
- const ScAddress& rPos, ScTokenArray& rCode);
DynamicKernel *mpKernel;
};
-void FormulaGroupInterpreterOpenCL::generateRPNCode(ScDocument& rDoc,
- const ScAddress& rPos, ScTokenArray& rCode)
-{
- // First, generate an RPN (reverse polish notation) token array.
- ScCompiler aComp(&rDoc, rPos, rCode);
- aComp.SetGrammar(rDoc.GetGrammar());
- aComp.CompileTokenArray(); // Create RPN token array.
-}
-
ScMatrixRef FormulaGroupInterpreterOpenCL::inverseMatrix( const ScMatrix& )
{
return NULL;
@@ -1439,7 +1428,6 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
const ScAddress& rTopPos, const ScFormulaCellGroupRef& xGroup,
ScTokenArray& rCode )
{
- generateRPNCode(rDoc, rTopPos, rCode);
// printf("Vector width = %d\n", xGroup->mnLength);
// Constructing "AST"
FormulaTokenIterator aCode = rCode;
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 257335909e81..8d87e246607a 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -425,7 +425,6 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
if (!pDest)
return false;
- generateRPNCode(rDoc, aTmpPos, aCode2);
ScInterpreter aInterpreter(pDest, &rDoc, aTmpPos, aCode2);
aInterpreter.Interpret();
aResults.push_back(aInterpreter.GetResultToken());
@@ -676,15 +675,6 @@ void FormulaGroupInterpreter::enableOpenCL(bool bEnable)
ScInterpreter::SetGlobalConfig(aConfig);
}
-void FormulaGroupInterpreter::generateRPNCode(ScDocument& rDoc, const ScAddress& rPos, ScTokenArray& rCode)
-{
- // First, generate an RPN (reverse polish notation) token array.
- ScCompiler aComp(&rDoc, rPos, rCode);
- aComp.SetGrammar(rDoc.GetGrammar());
- aComp.CompileTokenArray(); // Create RPN token array.
- // Now, calling FirstRPN() and NextRPN() will return tokens from the RPN token array.
-}
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index 4bdb6ae7a5ca..6f0c99168cb6 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -135,7 +135,10 @@ void applySharedFormulas(
aComp.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH_XL_OOX);
ScTokenArray* pArray = aComp.CompileString(rTokenStr);
if (pArray)
+ {
+ aComp.CompileTokenArray(); // Generate RPN tokens.
aGroups.set(nId, pArray);
+ }
}
}
@@ -222,6 +225,7 @@ void applyCellFormulas(
if (!pCode)
continue;
+ aCompiler.CompileTokenArray(); // Generate RPN tokens.
ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, pCode);
rDoc.setFormulaCell(aPos, pCell);
rCache.store(aPos, pCell);