[Libreoffice-commits] core.git: Branch 'feature/chart-3d-chart2' - 3 commits - formula/source include/formula sc/inc sc/source

Eike Rathke erack at redhat.com
Wed May 21 05:50:34 PDT 2014


 formula/source/core/api/token.cxx |   18 ++++++++++++++++++
 include/formula/tokenarray.hxx    |    1 +
 sc/inc/tokenarray.hxx             |    3 +++
 sc/source/core/data/document.cxx  |   11 ++++++++++-
 sc/source/core/tool/token.cxx     |   12 ++++++++++++
 sc/source/filter/xml/xmlcelli.cxx |   13 +++++++------
 6 files changed, 51 insertions(+), 7 deletions(-)

New commits:
commit a792b94fc56cb0992162e610bee7e5dbd9bd5cec
Author: Eike Rathke <erack at redhat.com>
Date:   Wed May 21 12:45:24 2014 +0200

    most certainly == was meant
    
    Change-Id: I1b0833daa576cd8603421e1036b8773badc8c775

diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 30b0e16..5309a40 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -690,7 +690,7 @@ void FormulaTokenArray::Assign( const FormulaTokenArray& r )
 /// Optimisiation for efficiently creating StringXML placeholders
 void FormulaTokenArray::Assign( sal_uInt16 nCode, FormulaToken **pTokens )
 {
-    assert( nLen = 0 );
+    assert( nLen == 0 );
     assert( pCode == NULL );
 
     nLen = nCode;
commit e1a120b434f42906ac066635d009f765e3eecb4a
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon May 19 20:23:07 2014 +0100

    ODS load perf: transfer ownership of the ScTokenArray to save cycles.
    
    Add API to wnsure we don't end up allocating 32k bytes of tokens
    for each ScFormulaToken, as happens when you Add a token to a new
    empty ScTokenArray.
    
    Change-Id: Ib12a3065eb513243a2146ebb009fbaa650385dd9

diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index c5d7da7..30b0e16 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -687,6 +687,24 @@ void FormulaTokenArray::Assign( const FormulaTokenArray& r )
     }
 }
 
+/// Optimisiation for efficiently creating StringXML placeholders
+void FormulaTokenArray::Assign( sal_uInt16 nCode, FormulaToken **pTokens )
+{
+    assert( nLen = 0 );
+    assert( pCode == NULL );
+
+    nLen = nCode;
+    pCode = new FormulaToken*[ nLen ];
+
+    for( sal_uInt16 i = 0; i < nLen; i++ )
+    {
+        FormulaToken *t = pTokens[ i ];
+        assert( t->GetOpCode() == ocStringXML );
+        pCode[ i ] = t;
+        t->IncRef();
+    }
+}
+
 FormulaTokenArray& FormulaTokenArray::operator=( const FormulaTokenArray& rArr )
 {
     Clear();
diff --git a/include/formula/tokenarray.hxx b/include/formula/tokenarray.hxx
index 5654a31..dcc8dc9 100644
--- a/include/formula/tokenarray.hxx
+++ b/include/formula/tokenarray.hxx
@@ -82,6 +82,7 @@ protected:
 
 protected:
     void                    Assign( const FormulaTokenArray& );
+    void                    Assign( sal_uInt16 nCode, FormulaToken **pTokens );
 
     /// Also used by the compiler. The token MUST had been allocated with new!
     FormulaToken*           Add( FormulaToken* );
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index c2191a8..9538819 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -110,6 +110,9 @@ public:
         NULL if there is no pCode (which actually would be caller's fault). */
     formula::FormulaToken* MergeRangeReference( const ScAddress & rPos );
 
+    /// Assign XML string placeholder to the array
+    void AssignXMLString( const OUString &rText, const OUString &rFormulaNmsp );
+
     /// Assignment with references to ScToken entries (not copied!)
     ScTokenArray& operator=( const ScTokenArray& );
 
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 4f4cbf6..4ac537f 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2083,6 +2083,18 @@ FormulaToken* ScTokenArray::AddColRowName( const ScSingleRefData& rRef )
     return Add( new ScSingleRefToken( rRef, ocColRowName ) );
 }
 
+void ScTokenArray::AssignXMLString( const OUString &rText, const OUString &rFormulaNmsp )
+{
+    sal_uInt16 nTokens = 1;
+    FormulaToken *aTokens[2];
+
+    aTokens[0] = new FormulaStringOpToken( ocStringXML, rText );
+    if( !rFormulaNmsp.isEmpty() )
+        aTokens[ nTokens++ ] = new FormulaStringOpToken( ocStringXML, rFormulaNmsp );
+
+    Assign( nTokens, aTokens );
+}
+
 bool ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend,
         const ScAddress& rPos, ScDirection eDir )
 {
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index b09f90c..4e4c552 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1362,7 +1362,6 @@ void ScXMLTableRowCellContext::PutFormulaCell( const ScAddress& rCellPos )
     ScDocumentImport& rDoc = rXMLImport.GetDoc();
 
     OUString aText = maFormula->first;
-    OUString aFormulaNmsp = maFormula->second;
 
     ::boost::scoped_ptr<ScExternalRefManager::ApiGuard> pExtRefGuard (
             new ScExternalRefManager::ApiGuard(pDoc));
@@ -1372,13 +1371,15 @@ void ScXMLTableRowCellContext::PutFormulaCell( const ScAddress& rCellPos )
         if ( aText[0] == '=' && aText.getLength() > 1 )
         {
             // temporary formula string as string tokens
-            boost::scoped_ptr<ScTokenArray> pCode(new ScTokenArray);
-            pCode->AddStringXML( aText );
-            if( (eGrammar == formula::FormulaGrammar::GRAM_EXTERNAL) && !aFormulaNmsp.isEmpty() )
-                pCode->AddStringXML( aFormulaNmsp );
+            ScTokenArray *pCode = new ScTokenArray();
+
+            OUString aFormulaNmsp = maFormula->second;
+            if( eGrammar != formula::FormulaGrammar::GRAM_EXTERNAL )
+                aFormulaNmsp = OUString();
+            pCode->AssignXMLString( aText, aFormulaNmsp );
 
             rDoc.getDoc().IncXMLImportedFormulaCount( aText.getLength() );
-            ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, rCellPos, *pCode, eGrammar, MM_NONE);
+            ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, rCellPos, pCode, eGrammar, MM_NONE);
             SetFormulaCell(pNewCell);
             rDoc.setFormulaCell(rCellPos, pNewCell);
 
commit 4bbc5b63968f975c3f7ba0ba88f30739c5eb8ca6
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Tue May 20 08:13:53 2014 +0100

    ODS load perf: avoid excessive calls to uppercase to compare tab names.
    
    Change-Id: I37b9e49607c8c51f10bc8ff8fc342b02fdb8b7e1

diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index d72e7db..97c10ca 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -237,7 +237,16 @@ bool ScDocument::GetCodeName( SCTAB nTab, OUString& rName ) const
 
 bool ScDocument::GetTable( const OUString& rName, SCTAB& rTab ) const
 {
-    OUString aUpperName = ScGlobal::pCharClass->uppercase(rName);
+    OUString aUpperName;
+    static OUString aCacheName, aCacheUpperName;
+
+    if (aCacheName != rName)
+    {
+        aCacheName = rName;
+        // surprisingly slow ...
+        aCacheUpperName = ScGlobal::pCharClass->uppercase(rName);
+    }
+    aUpperName = aCacheUpperName;
 
     for (SCTAB i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
         if (maTabs[i])


More information about the Libreoffice-commits mailing list