checkpoint
authoradam <adam@megacz.com>
Wed, 4 Jan 2006 12:20:02 +0000 (07:20 -0500)
committeradam <adam@megacz.com>
Wed, 4 Jan 2006 12:20:02 +0000 (07:20 -0500)
darcs-hash:20060104122002-5007d-e3168202afb862d070042071ceb1950df4d4549c.gz

TODO
src/edu/berkeley/sbp/GSS.java
src/edu/berkeley/sbp/Parser.java
src/edu/berkeley/sbp/util/FastSet.java
src/edu/berkeley/sbp/util/TopologicalBag.java

diff --git a/TODO b/TODO
index 5f5e1cf..3e67a2e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,20 @@
 _____________________________________________________________________________
 Immediately
 
+  - Performance
+
+     - Next target: TopologicalBag (make it wickedfast: preoptimize)
+
+     - Forest: keep() and valid() -- can we do this with states
+       rather than subtrees?
+
+     - hash Long->long: it's all bogus
+
+  * huge performance improvement (try for more)
+  * pick back up cleaning up end of Parser.java (Reduction)
+  * some weird edge cases; check last regression test, 'make doc'
+
+
   - Sensible tree-printout
   - make Tib.Block extend Tree<>
 
index 0bc14ae..645fa8f 100644 (file)
@@ -92,8 +92,7 @@ class GSS {
                 if (token==null) break;
                 int count = 0;
                 Parser.Table.Reduction r = null;
-                for(Parser.Table.Reduction red : token==null ? state.getEofReductions() : state.getReductions(token)) { r = red; count++; }
-                if (count==0) return;     // BEWARE! this optimization is suspected to cause really nasty heisenbugs
+                if (!state.hasReductions(token)) return;
                 //if (count > 1) break;
                 //if (r.numPop == 0) break;
                 //r.reduce(pending, parent, null, Phase.this, null);
@@ -223,7 +222,7 @@ class GSS {
             private Node(Node parent, Forest pending, Parser.Table.State state, Phase start) {
                 this.state = state;
                 if (pending != null) this.holder().merge(pending);
-                if (parent != null) parents().add(parent, true);
+                if (parent != null) parents().add(parent);
                 if (Phase.this.hash.get(code(state, start)) != null) throw new Error("severe problem!");
                 Phase.this.hash.put(code(state, start), this);
                 Phase.this.numNodes++;
index 868b200..5c399cc 100644 (file)
@@ -185,6 +185,7 @@ public abstract class Parser<T extends Token, R> {
             public Iterable<State>     getShifts(Token t)          { return shifts.get(t); }
             public boolean             isAccepting()               { return accept; }
             public Iterable<Reduction> getReductions(Token t)      { return t==null ? eofReductions : reductions.get(t); }
+            public boolean             hasReductions(Token t)      { return t==null ? eofReductions.size()>0 : reductions.has(t); }
             public Iterable<Reduction> getEofReductions()          { return eofReductions; }
             public Iterator<Position>  iterator()                  { return hs.iterator(); }
 
index d3be774..bdfa380 100644 (file)
@@ -3,9 +3,9 @@ import java.util.*;
 
 public /*final*/ class FastSet<T> implements Iterator<T>, Iterable<T> {
 
-    public static final int INITIAL_SIZE = 128;
+    public static final int INITIAL_SIZE = 8;
 
-    private       Object[] array;
+    private       Object[] array = null;
     private       T        only  = null;
     private       int      i     = -1;
     private       int      size  = 0;
@@ -39,7 +39,8 @@ public /*final*/ class FastSet<T> implements Iterator<T>, Iterable<T> {
         }
     }
     public void add(T t, boolean check) {
-        if (check) for(Object o : this) if (o.equals(t)) return;
+        //if (check) for(Object o : this) if (o.equals(t)) return;
+        if (check) for(Object o : this) if (o==t) return;
         add(t);
     }
     public void add(T t) {
index 8862be6..cdbe976 100644 (file)
@@ -91,6 +91,13 @@ public class TopologicalBag<K,V> implements MapBag<Topology<K>,V> {
         return false;
     }
 
+    public boolean has(K k) {
+        for(Topology<K> t : h.keySet())
+            if (t.contains(k) && !h.get(t).isEmpty())
+                return true;
+        return false;
+    }
+
     private HashMap<K,Iterable<V>> cache = new HashMap<K,Iterable<V>>();
     public Iterable<V> getAll(Topology<K> k) { return h.get(k); }
     public Iterable<V> get(K k) {