[Libreoffice-commits] core.git: Branch 'feature/fixes6' - sc/inc sc/source

Michael Meeks michael.meeks at collabora.com
Wed Jul 15 12:00:59 PDT 2015


 sc/inc/cellvalue.hxx               |   18 ++++++++++----
 sc/inc/queryparam.hxx              |    7 +++--
 sc/source/core/data/cellvalue.cxx  |   17 -------------
 sc/source/core/data/table3.cxx     |   45 ++++++++++++++++++++++++++-----------
 sc/source/core/tool/queryparam.cxx |   15 ------------
 5 files changed, 49 insertions(+), 53 deletions(-)

New commits:
commit de498a7edfcf0529c104028922da1308870a21dc
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Jul 15 20:04:43 2015 +0100

    Save 12% on a large SUMIFs calculation with some trivial tweaks.
    
    50bn cycles of 400bn spent in these out-of-lined methods. So -
    in-line a few methods for a handful of bn cycles each across 1bn
    calls. Remove redundant destructor for 30bn, in-line isEmpty for
    8bn, avoid fetching globals unless we need them etc.
    
    Change-Id: I1f5c1e08a07c59a41810bca385409ca89021322d

diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 3a2d3c8..ca751d0 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -112,7 +112,6 @@ struct SC_DLLPUBLIC ScRefCellValue
     ScRefCellValue( const EditTextObject* pEditText );
     ScRefCellValue( ScFormulaCell* pFormula );
     ScRefCellValue( const ScRefCellValue& r );
-    ~ScRefCellValue();
 
     void clear();
 
@@ -143,15 +142,24 @@ struct SC_DLLPUBLIC ScRefCellValue
      */
     OUString getString( const ScDocument* pDoc );
 
-    bool isEmpty() const;
-
     bool hasEmptyValue();
 
     bool equalsWithoutFormat( const ScRefCellValue& r ) const;
 
-    ScRefCellValue& operator= ( const ScRefCellValue& r );
-
     void swap( ScRefCellValue& r );
+
+    // Called extremely frequently by query iterators
+
+    inline bool isEmpty() const { return meType == CELLTYPE_NONE; }
+
+    inline ScRefCellValue& operator= ( const ScRefCellValue& r )
+    {
+        // double is 8 bytes, whereas a pointer may be 4 or 8 bytes
+        // depending on the platform. So assign double value.
+        meType = r.meType;
+        mfValue = r.mfValue;
+        return *this;
+    }
 };
 
 #endif
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index 867b15d..17f366b 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -50,9 +50,10 @@ struct ScQueryParamBase
 
     virtual bool IsValidFieldIndex() const;
 
-    SC_DLLPUBLIC SCSIZE GetEntryCount() const;
-    SC_DLLPUBLIC const ScQueryEntry& GetEntry(SCSIZE n) const;
-    SC_DLLPUBLIC ScQueryEntry& GetEntry(SCSIZE n);
+    inline SCSIZE GetEntryCount() const                 { return maEntries.size(); }
+    inline const ScQueryEntry& GetEntry(SCSIZE n) const { return maEntries[n]; }
+    inline ScQueryEntry& GetEntry(SCSIZE n)             { return maEntries[n]; }
+
     SC_DLLPUBLIC ScQueryEntry& AppendEntry();
     ScQueryEntry* FindEntryByField(SCCOLROW nField, bool bNew);
     SC_DLLPUBLIC void RemoveEntryByField(SCCOLROW nField);
diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx
index e03870c..18c5061 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -518,11 +518,6 @@ ScRefCellValue::ScRefCellValue( ScFormulaCell* pFormula ) : meType(CELLTYPE_FORM
 // as the pointer values.
 ScRefCellValue::ScRefCellValue( const ScRefCellValue& r ) : meType(r.meType), mfValue(r.mfValue) {}
 
-ScRefCellValue::~ScRefCellValue()
-{
-    clear();
-}
-
 void ScRefCellValue::clear()
 {
     // Reset to empty value.
@@ -589,11 +584,6 @@ OUString ScRefCellValue::getString( const ScDocument* pDoc )
     return getStringImpl(*this, pDoc);
 }
 
-bool ScRefCellValue::isEmpty() const
-{
-    return meType == CELLTYPE_NONE;
-}
-
 bool ScRefCellValue::hasEmptyValue()
 {
     if (isEmpty())
@@ -610,13 +600,6 @@ bool ScRefCellValue::equalsWithoutFormat( const ScRefCellValue& r ) const
     return equalsWithoutFormatImpl(*this, r);
 }
 
-ScRefCellValue& ScRefCellValue::operator= ( const ScRefCellValue& r )
-{
-    ScRefCellValue aTmp(r);
-    swap(aTmp);
-    return *this;
-}
-
 void ScRefCellValue::swap( ScRefCellValue& r )
 {
     std::swap(meType, r.meType);
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 6b5f634..faa9105 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2232,6 +2232,32 @@ class QueryEvaluator
         return (rEntry.eOp == SC_LESS_EQUAL || rEntry.eOp == SC_GREATER_EQUAL);
     }
 
+    // non-negligable cost of doing this work if we don't need to.
+
+    utl::TransliterationWrapper* getTransliteration()
+    {
+        if (!mpTransliteration)
+        {
+            if (mrParam.bCaseSens)
+                mpTransliteration = ScGlobal::GetCaseTransliteration();
+            else
+                mpTransliteration = ScGlobal::GetpTransliteration();
+        }
+        return mpTransliteration;
+    }
+
+    CollatorWrapper* getCollator()
+    {
+        if (!mpCollator)
+        {
+            if (mrParam.bCaseSens)
+                mpCollator = ScGlobal::GetCaseCollator();
+            else
+                mpCollator = ScGlobal::GetCollator();
+        }
+        return mpCollator;
+    }
+
 public:
     QueryEvaluator(ScDocument& rDoc, const ScTable& rTab, const ScQueryParam& rParam,
                    const bool* pTestEqualCondition) :
@@ -2240,18 +2266,10 @@ public:
         mrTab(rTab),
         mrParam(rParam),
         mpTestEqualCondition(pTestEqualCondition),
+        mpTransliteration(NULL),
+        mpCollator(NULL),
         mbMatchWholeCell(rDoc.GetDocOptions().IsMatchWholeCell())
     {
-        if (rParam.bCaseSens)
-        {
-            mpTransliteration = ScGlobal::GetCaseTransliteration();
-            mpCollator = ScGlobal::GetCaseCollator();
-        }
-        else
-        {
-            mpTransliteration = ScGlobal::GetpTransliteration();
-            mpCollator = ScGlobal::GetCollator();
-        }
     }
 
     bool isQueryByValue(
@@ -2493,10 +2511,11 @@ public:
                 else
                 {
                     OUString aQueryStr = rItem.maString.getString();
-                    OUString aCell( mpTransliteration->transliterate(
+                    utl::TransliterationWrapper *pTransliteration = getTransliteration();
+                    OUString aCell( pTransliteration->transliterate(
                         aCellStr.getString(), ScGlobal::eLnge, 0, aCellStr.getLength(),
                         NULL ) );
-                    OUString aQuer( mpTransliteration->transliterate(
+                    OUString aQuer( pTransliteration->transliterate(
                         aQueryStr, ScGlobal::eLnge, 0, aQueryStr.getLength(),
                         NULL ) );
                     sal_Int32 nIndex = (rEntry.eOp == SC_ENDS_WITH || rEntry.eOp == SC_DOES_NOT_END_WITH) ?
@@ -2533,7 +2552,7 @@ public:
             }
             else
             {   // use collator here because data was probably sorted
-                sal_Int32 nCompare = mpCollator->compareString(
+                sal_Int32 nCompare = getCollator()->compareString(
                     aCellStr.getString(), rItem.maString.getString());
                 switch (rEntry.eOp)
                 {
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index 099b55d..5c60a5b 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -89,21 +89,6 @@ bool ScQueryParamBase::IsValidFieldIndex() const
     return true;
 }
 
-SCSIZE ScQueryParamBase::GetEntryCount() const
-{
-    return maEntries.size();
-}
-
-const ScQueryEntry& ScQueryParamBase::GetEntry(SCSIZE n) const
-{
-    return maEntries[n];
-}
-
-ScQueryEntry& ScQueryParamBase::GetEntry(SCSIZE n)
-{
-    return maEntries[n];
-}
-
 ScQueryEntry& ScQueryParamBase::AppendEntry()
 {
     // Find the first unused entry.


More information about the Libreoffice-commits mailing list