[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Wed May 15 09:55:10 PDT 2013


 sc/source/core/data/column2.cxx |   34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

New commits:
commit 675e9f4f402086cdd16730865fcea8eeed739a64
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed May 15 12:55:02 2013 -0400

    Avoid expensive element position lookup twice.
    
    This moderately improves the performance of pasting a large array
    of formula cells.
    
    Change-Id: I27a59ff348cb715df15db80693cb7d193e67ec2e

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 1df0d9d..400488b 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1864,13 +1864,37 @@ void ScColumn::FindUsed( SCROW nStartRow, SCROW nEndRow, bool* pUsed ) const
 
 void ScColumn::StartListening( SvtListener& rLst, SCROW nRow )
 {
-    SvtBroadcaster* pBC = GetBroadcaster(nRow);
-    if (!pBC)
+    std::pair<BCStoreType::iterator,size_t> aPos = maBroadcasters.position(nRow);
+    BCStoreType::iterator it = aPos.first; // block position.
+    size_t nElemPos = aPos.second; // element position within the block.
+    switch (it->type)
     {
-        pBC = new SvtBroadcaster;
-        maBroadcasters.set(nRow, pBC);
+        case sc::element_type_broadcaster:
+        {
+            // Broadcaster already exists here.
+            sc::custom_broadcaster_block::iterator itData = sc::custom_broadcaster_block::begin(*it->data);
+            std::advance(itData, nElemPos);
+            SvtBroadcaster* pBC = *itData;
+            rLst.StartListening(*pBC);
+        }
+        break;
+        case mdds::mtv::element_type_empty:
+        {
+            // No broadcaster exists at this position yet.
+            SvtBroadcaster* pBC = new SvtBroadcaster;
+            rLst.StartListening(*pBC);
+            maBroadcasters.set(it, nRow, pBC);
+        }
+        break;
+        default:
+#if DEBUG_COLUMN_STORAGE
+            cout << "ScColumn::StartListening: wrong block type encountered in the broadcaster storage." << endl;
+            cout.flush();
+            abort();
+#else
+            ;
+#endif
     }
-    rLst.StartListening(*pBC);
 }
 
 void ScColumn::MoveListeners( SvtBroadcaster& rSource, SCROW nDestRow )


More information about the Libreoffice-commits mailing list