[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    patch for more efficiency and "Circle" explained
From:       John Dailey <dailey () vt ! edu>
Date:       2002-08-29 3:27:42
[Download RAW message or body]

This patch reduces the amount of wasted recalculation done.

Also, I found the problem behind all the "Error: Circle" being dumped to the 
output.  Think of a situation where A1 depends on A2.  A1 is being calculated 
and in the middle, A2->calc() is started.  A2 finishes calculating, and since 
A1 depends on A2, A1 is calculated.  This 2nd call to A1->calc() gives the 
circle error, but then when the stack unwinds, the 1st A1->calc() finishes 
normally so there isn't any real problem except the alarming output to the 
screen.

-John
["fewerRecalcs.diff" (text/x-diff)]

Index: kspread_cell.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_cell.cc,v
retrieving revision 1.440
diff -p -u -3 -r1.440 kspread_cell.cc
--- kspread_cell.cc	2002/08/29 00:53:56	1.440
+++ kspread_cell.cc	2002/08/29 03:13:35
@@ -1753,6 +1753,8 @@ bool KSpreadCell::calc(bool delay)
     KSpreadDependency * d = 0;
     KSpreadCell *cell = 0;
     // Every cell that references us must calculate with this new value
+
+    // first set them all calcdirty
     for (d = m_lstDependingOnMe.first(); d != NULL; d = m_lstDependingOnMe.next())
     {
       for (int c = d->Left(); c <= d->Right(); c++)
@@ -1762,6 +1764,21 @@ bool KSpreadCell::calc(bool delay)
             cell = d->Table()->cellAt( c, r );
             cell->clearAllErrors();
             cell->setFlag( Flag_CalcDirty );
+        }
+      }
+    }
+
+    // then calculate them all
+    /* setting calcdirty and calculation is done as a separate step to
+       help prevent massive amounts of duplicated calculation
+    */
+    for (d = m_lstDependingOnMe.first(); d != NULL; d = m_lstDependingOnMe.next())
+    {
+      for (int c = d->Left(); c <= d->Right(); c++)
+      {
+        for (int r = d->Top(); r <= d->Bottom(); r++)
+        {
+            cell = d->Table()->cellAt( c, r );
             cell->calc();
         }
       }
@@ -3631,7 +3648,7 @@ void KSpreadCell::updateDepending()
 
   setFlag(Flag_UpdatingDeps);
 
-  KSpreadCell * cell; 
+  KSpreadCell * cell;
   // Every cell that references us must calculate with this new value
   for (d = m_lstDependingOnMe.first(); d != NULL; d = m_lstDependingOnMe.next())
   {

_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic