questionable hack to reduce maximum stack depth
authoradam <adam@megacz.com>
Sat, 16 Sep 2006 07:30:30 +0000 (03:30 -0400)
committeradam <adam@megacz.com>
Sat, 16 Sep 2006 07:30:30 +0000 (03:30 -0400)
darcs-hash:20060916073030-5007d-6ea0b85b09cbde909e87503669317c4247f3e32c.gz

src/edu/berkeley/sbp/GSS.java

index 5255a21..ac62e18 100644 (file)
@@ -196,6 +196,8 @@ class GSS {
             return true;
         }
 
+        LinkedList<Node> reductionQueue = new LinkedList<Node>();
+
         /** perform all reduction operations */
         public void reduce() throws ParseFailed {
             try {
@@ -210,9 +212,11 @@ class GSS {
                     // INVARIANT: we never "see" a node until its parent-set is complete, modulo merges
                 }
                 for(int i=0; i<num; i++) {
-                    Node n = reducing_list[i];
+                    reductionQueue.add(reducing_list[i]);
                     reducing_list[i] = null;
-                    n.performReductions();
+                }
+                while(!reductionQueue.isEmpty()) {
+                    reductionQueue.remove().performReductions();
                 }
                 if (reset) {
                     reset = false;
@@ -301,8 +305,6 @@ class GSS {
         /** a node in the GSS */
         final class Node implements Invokable<Position, Node, Node>, IntegerMappable, GraphViz.ToGraphViz {
             public FastSet<Node> set = new FastSet<Node>();
-
-           
             private boolean allqueued = false;
 
             /** what state this node is in */
@@ -337,7 +339,7 @@ class GSS {
             }
 
             public void performReductions(Node n2) {
-                if (!allqueued) performReductions();
+                if (!allqueued) reductionQueue.add(this);//performReductions();
                 else            state.invokeReductions(token, this, this, n2);
             }