[Libreoffice-commits] core.git: Branch 'private/kohei/calc-shared-string' - include/svl sc/source svl/source

Kohei Yoshida kohei.yoshida at collabora.com
Wed Oct 9 07:07:43 PDT 2013


 include/svl/sharedstring.hxx       |    1 
 sc/source/core/data/document.cxx   |   43 +++++++++++++++++++++++++++++++++++++
 sc/source/core/data/table3.cxx     |    2 -
 sc/source/core/tool/interpr1.cxx   |    2 -
 sc/source/core/tool/queryentry.cxx |    4 +--
 svl/source/misc/sharedstring.cxx   |    5 ++++
 6 files changed, 53 insertions(+), 4 deletions(-)

New commits:
commit bb71417fae739d94f610d03ece554dab03efacea
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Oct 9 10:08:06 2013 -0400

    Add isEmpty() to SharedString. This simplies a lot of its call sites.
    
    Change-Id: I0ebc43abe59ac317c053a4f606dbe376d85c03b0

diff --git a/include/svl/sharedstring.hxx b/include/svl/sharedstring.hxx
index 1e16c53..183dc43 100644
--- a/include/svl/sharedstring.hxx
+++ b/include/svl/sharedstring.hxx
@@ -40,6 +40,7 @@ public:
     const rtl_uString* getDataIgnoreCase() const;
 
     bool isValid() const;
+    bool isEmpty() const;
 };
 
 }
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 51a5c2e..46d4f3f 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -101,6 +101,48 @@
 #include <limits>
 #include <boost/scoped_ptr.hpp>
 
+#include <stdio.h>
+#include <string>
+#include <sys/time.h>
+
+namespace {
+
+class stack_printer
+{
+public:
+    explicit stack_printer(const char* msg) :
+        msMsg(msg)
+    {
+        fprintf(stdout, "%s: --begin\n", msMsg.c_str());
+        mfStartTime = getTime();
+    }
+
+    ~stack_printer()
+    {
+        double fEndTime = getTime();
+        fprintf(stdout, "%s: --end (duration: %g sec)\n", msMsg.c_str(), (fEndTime - mfStartTime));
+    }
+
+    void printTime(int line) const
+    {
+        double fEndTime = getTime();
+        fprintf(stdout, "%s: --(%d) (duration: %g sec)\n", msMsg.c_str(), line, (fEndTime - mfStartTime));
+    }
+
+private:
+    double getTime() const
+    {
+        timeval tv;
+        gettimeofday(&tv, NULL);
+        return tv.tv_sec + tv.tv_usec / 1000000.0;
+    }
+
+    ::std::string msMsg;
+    double mfStartTime;
+};
+
+}
+
 using ::editeng::SvxBorderLine;
 using namespace ::com::sun::star;
 
@@ -3597,6 +3639,7 @@ void ScDocument::AddTableOpFormulaCell( ScFormulaCell* pCell )
 
 void ScDocument::CalcAll()
 {
+    stack_printer __stack_printer__("ScDocument::CalcAll");
     ClearLookupCaches();    // Ensure we don't deliver zombie data.
     sc::AutoCalcSwitch aSwitch(*this, true);
     TableContainer::iterator it = maTabs.begin();
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 9b63531..10c7ca7 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1487,7 +1487,7 @@ public:
             // Simple string matching i.e. no regexp match.
             if (isTextMatchOp(rEntry))
             {
-                if (rItem.meType != ScQueryEntry::ByString && rItem.maString.getString().isEmpty())
+                if (rItem.meType != ScQueryEntry::ByString && rItem.maString.isEmpty())
                 {
                     // #i18374# When used from functions (match, countif, sumif, vlookup, hlookup, lookup),
                     // the query value is assigned directly, and the string is empty. In that case,
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 9400bec..314c2ca 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -976,7 +976,7 @@ double ScInterpreter::CompareFunc( const ScCompare& rComp, ScCompareOptions* pOp
         if (!rItems.empty())
         {
             const ScQueryEntry::Item& rItem = rItems[0];
-            if (rItem.meType != ScQueryEntry::ByString && !rItem.maString.getString().isEmpty() &&
+            if (rItem.meType != ScQueryEntry::ByString && !rItem.maString.isEmpty() &&
                 (rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL))
             {
                 // As in ScTable::ValidQuery() match a numeric string for a
diff --git a/sc/source/core/tool/queryentry.cxx b/sc/source/core/tool/queryentry.cxx
index f933516..a282f4d 100644
--- a/sc/source/core/tool/queryentry.cxx
+++ b/sc/source/core/tool/queryentry.cxx
@@ -107,7 +107,7 @@ bool ScQueryEntry::IsQueryByEmpty() const
     const Item& rItem = maQueryItems[0];
     return eOp == SC_EQUAL &&
         rItem.meType == ByEmpty &&
-        rItem.maString.getString().isEmpty() &&
+        rItem.maString.isEmpty() &&
         rItem.mfVal == SC_EMPTYFIELDS;
 }
 
@@ -129,7 +129,7 @@ bool ScQueryEntry::IsQueryByNonEmpty() const
     const Item& rItem = maQueryItems[0];
     return eOp == SC_EQUAL &&
         rItem.meType == ByEmpty &&
-        rItem.maString.getString().isEmpty() &&
+        rItem.maString.isEmpty() &&
         rItem.mfVal == SC_NONEMPTYFIELDS;
 }
 
diff --git a/svl/source/misc/sharedstring.cxx b/svl/source/misc/sharedstring.cxx
index 5eb3af5..9c0cad2f 100644
--- a/svl/source/misc/sharedstring.cxx
+++ b/svl/source/misc/sharedstring.cxx
@@ -113,6 +113,11 @@ bool SharedString::isValid() const
     return mpData != NULL;
 }
 
+bool SharedString::isEmpty() const
+{
+    return mpData == NULL || mpData->length == 0;
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list