checkpoint
authoradam <adam@megacz.com>
Wed, 4 Jan 2006 09:42:09 +0000 (04:42 -0500)
committeradam <adam@megacz.com>
Wed, 4 Jan 2006 09:42:09 +0000 (04:42 -0500)
darcs-hash:20060104094209-5007d-4753c4a3f52bb2f70d1be0778f8cd7252404fcd1.gz

src/edu/berkeley/sbp/GSS.java

index abe4aa3..6db929b 100644 (file)
@@ -27,6 +27,8 @@ class GSS {
 
     public GSS() { }
 
+    private Phase.Node[] reducing_list = null;
+
     /** corresponds to a positions <i>between tokens</i> the input stream; same as Tomita's U_i's */
     public class Phase {
 
@@ -107,10 +109,17 @@ class GSS {
         /** perform all reduction operations */
         public void reduce() {
             reducing = true;
-            HashSet<Phase.Node> s = new HashSet<Phase.Node>();
-            s.addAll(hash.values());
-            for(Phase.Node n : s) n.queueEmptyReductions();
-            for(Phase.Node n : s) n.queueReductions();
+            if (reducing_list==null || reducing_list.length < hash.size())
+                reducing_list = new Phase.Node[hash.size() * 4];
+            Collection<Node> hv = hash.values();
+            hv.toArray(reducing_list);
+            int num = hv.size();
+            for(int i=0; i<num; i++) {
+                Node n = reducing_list[i];
+                reducing_list[i] = null;
+                n.queueEmptyReductions();
+                n.queueReductions();
+            }
         }
 
         /** perform all shift operations, adding promoted nodes to <tt>next</tt> */