[Libreoffice-commits] core.git: Branch 'private/kohei/xlsx-import-speedup' - 2 commits - formula/source sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Tue Nov 12 11:42:47 PST 2013


 formula/source/core/resource/core_resource.src |   23 ++++++++++++++---------
 sc/inc/formulagroup.hxx                        |    2 --
 sc/source/core/data/formulacell.cxx            |    6 ++++++
 sc/source/core/opencl/formulagroupcl.cxx       |   12 ------------
 sc/source/core/tool/formulagroup.cxx           |   10 ----------
 sc/source/filter/oox/formulabuffer.cxx         |    4 ++++
 6 files changed, 24 insertions(+), 33 deletions(-)

New commits:
commit a2a99633067f25e0d2e30974f9af903485ea2c90
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Nov 12 14:43:41 2013 -0500

    Reduce the amount of RPM token generation.
    
    Change-Id: I03941690114b17d8ab63cfb9b1b23a2ff1741b10

diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index 24e26d9..fb7692b 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -85,8 +85,6 @@ class SC_DLLPUBLIC FormulaGroupInterpreter
     FormulaGroupInterpreter() {}
     virtual ~FormulaGroupInterpreter() {}
 
-    static void generateRPNCode(ScDocument& rDoc, const ScAddress& rPos, ScTokenArray& rCode);
-
  public:
     static FormulaGroupInterpreter *getStatic();
     static void fillOpenCLInfo(std::vector<OpenclPlatformInfo>& rPlatforms);
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 5e92efa..07f8656 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 228df59..66a28ce 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1408,20 +1408,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;
@@ -1431,7 +1420,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 2573359..8d87e24 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 4bdb6ae..6f0c991 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);
commit 1a53a5771d609a0f7a795ef075a5f69b0c294ece
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Nov 11 17:02:42 2013 -0500

    More Excel functions with _xlfn. prefix.
    
    Change-Id: I49d29fe626ea3079273b4e654a6a3803f7dbd614

diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src
index 06e39e7..1d29ce8 100644
--- a/formula/source/core/resource/core_resource.src
+++ b/formula/source/core/resource/core_resource.src
@@ -382,6 +382,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF
     String SC_OPCODE_WEBSERVICE    { Text = "COM.MICROSOFT.WEBSERVICE"; };
 };
 
+/** These function names are used only in the XLSX import. */
 Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML
 {
     String SC_OPCODE_IF { Text = "IF" ; };
@@ -544,14 +545,14 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML
     String SC_OPCODE_VAR_A { Text = "VARA" ; };
     String SC_OPCODE_VAR_P { Text = "VARP" ; };
     String SC_OPCODE_VAR_P_A { Text = "VARPA" ; };
-    String SC_OPCODE_VAR_P_MS { Text = "VAR.P" ; };
-    String SC_OPCODE_VAR_S { Text = "VAR.S" ; };
+    String SC_OPCODE_VAR_P_MS { Text = "_xlfn.VAR.P" ; };
+    String SC_OPCODE_VAR_S { Text = "_xlfn.VAR.S" ; };
     String SC_OPCODE_ST_DEV { Text = "STDEV" ; };
     String SC_OPCODE_ST_DEV_A { Text = "STDEVA" ; };
     String SC_OPCODE_ST_DEV_P { Text = "STDEVP" ; };
     String SC_OPCODE_ST_DEV_P_A { Text = "STDEVPA" ; };
-    String SC_OPCODE_ST_DEV_P_MS { Text = "STDEV.P" ; };
-    String SC_OPCODE_ST_DEV_S { Text = "STDEV.S" ; };
+    String SC_OPCODE_ST_DEV_P_MS { Text = "_xlfn.STDEV.P" ; };
+    String SC_OPCODE_ST_DEV_S { Text = "_xlfn.STDEV.S" ; };
     String SC_OPCODE_B { Text = "B" ; };
     String SC_OPCODE_NORM_DIST { Text = "NORMDIST" ; };
     String SC_OPCODE_EXP_DIST { Text = "EXPONDIST" ; };
@@ -645,6 +646,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML
     String SC_OPCODE_T_DIST { Text = "TDIST" ; };
     String SC_OPCODE_F_DIST { Text = "FDIST" ; };
     String SC_OPCODE_CHI_DIST { Text = "CHIDIST" ; };
+    String SC_OPCODE_CHI_DIST_MS { Text = "_xlfn.CHISQ.DIST.RT" ; };
     String SC_OPCODE_WEIBULL { Text = "WEIBULL" ; };
     String SC_OPCODE_NEG_BINOM_VERT { Text = "NEGBINOMDIST" ; };
     String SC_OPCODE_KRIT_BINOM { Text = "CRITBINOM" ; };
@@ -675,8 +677,8 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML
     String SC_OPCODE_PROB { Text = "PROB" ; };
     String SC_OPCODE_CORREL { Text = "CORREL" ; };
     String SC_OPCODE_COVAR { Text = "COVAR" ; };
-    String SC_OPCODE_COVARIANCE_P { Text = "COVARIANCE.P" ; };
-    String SC_OPCODE_COVARIANCE_S { Text = "COVARIANCE.S" ; };
+    String SC_OPCODE_COVARIANCE_P { Text = "_xlfn.COVARIANCE.P" ; };
+    String SC_OPCODE_COVARIANCE_S { Text = "_xlfn.COVARIANCE.S" ; };
     String SC_OPCODE_PEARSON { Text = "PEARSON" ; };
     String SC_OPCODE_RSQ { Text = "RSQ" ; };
     String SC_OPCODE_STEYX { Text = "STEYX" ; };
@@ -688,6 +690,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML
     String SC_OPCODE_RKP { Text = "LOGEST" ; };
     String SC_OPCODE_FORECAST { Text = "FORECAST" ; };
     String SC_OPCODE_CHI_INV { Text = "CHIINV" ; };
+    String SC_OPCODE_CHI_INV_MS { Text = "_xlfn.CHISQ.INV.RT" ; };
     String SC_OPCODE_GAMMA_DIST { Text = "GAMMADIST" ; };
     String SC_OPCODE_GAMMA_INV { Text = "GAMMAINV" ; };
     String SC_OPCODE_T_INV { Text = "TINV" ; };
@@ -713,13 +716,15 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML
     String SC_OPCODE_ARABIC { Text = "ARABIC" ; };
     String SC_OPCODE_HYPERLINK { Text = "HYPERLINK" ; };
     String SC_OPCODE_INFO { Text = "INFO" ; };
-    String SC_OPCODE_BAHTTEXT { Text = "BAHTTEXT" ; };
+    String SC_OPCODE_BAHTTEXT { Text = "_xlfn.BAHTTEXT" ; };
     String SC_OPCODE_GET_PIVOT_DATA { Text = "GETPIVOTDATA" ; };
     String SC_OPCODE_EUROCONVERT { Text = "EUROCONVERT" ; };
     String SC_OPCODE_NUMBERVALUE { Text = "NUMBERVALUE" ; };
     String SC_OPCODE_GAMMA { Text = "GAMMA" ; };
     String SC_OPCODE_CHISQ_DIST { Text = "CHISQDIST" ; };
+    String SC_OPCODE_CHISQ_DIST_MS { Text = "_xlfn.CHISQ.DIST" ; };
     String SC_OPCODE_CHISQ_INV { Text = "CHISQINV" ;};
+    String SC_OPCODE_CHISQ_INV_MS { Text = "_xlfn.CHISQ.INV" ;};
     String SC_OPCODE_BITAND    { Text = "BITAND" ;};
     String SC_OPCODE_BITOR    { Text = "BITOR" ;};
     String SC_OPCODE_BITXOR    { Text = "BITXOR" ;};
@@ -734,8 +739,8 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML
     String SC_OPCODE_ERROR_NUM     { Text = "#NUM!"   ; };
     String SC_OPCODE_ERROR_NA      { Text = "#N/A"    ; };
     /* END defined ERROR.TYPE() values. */
-    String SC_OPCODE_FILTERXML     { Text = "FILTERXML";};
-    String SC_OPCODE_WEBSERVICE    { Text = "WEBSERVICE"; };
+    String SC_OPCODE_FILTERXML     { Text = "_xlfn.FILTERXML";};
+    String SC_OPCODE_WEBSERVICE    { Text = "_xlfn.WEBSERVICE"; };
 };
 
 // DO NOT CHANGE NAMES! Only add functions.


More information about the Libreoffice-commits mailing list