Nice/src/mlsub/typing/lowlevel Domain.java,1.4,1.5 DomainVector.java,1.3,1.4 K0.java,1.24,1.25 LowlevelUnsatisfiable.java,1.1,1.2 Satisfier.java,1.1,1.2

Daniel Bonniot <[email protected]> Tue, 29 Mar 2005 15:33:05 +0000
Newsgroups gmane.comp.lang.nice.cvs
Message-ID <[email protected]>
Update of /cvsroot/nice/Nice/src/mlsub/typing/lowlevel
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18383/src/mlsub/typing/lowlevel

Modified Files:
	Domain.java DomainVector.java K0.java 
	LowlevelUnsatisfiable.java Satisfier.java 
Log Message:
Optim: use shared exception instances instead of dynamically created ones for stateless exceptions, since fillInStackTrace is expensive

Index: DomainVector.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/DomainVector.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** DomainVector.java	23 May 2003 13:05:30 -0000	1.3
--- DomainVector.java	29 Mar 2005 15:33:02 -0000	1.4
***************
*** 121,125 ****
          // XXX: already tested ??
          if (dx.isEmpty()) {
!           throw new LowlevelUnsatisfiable();
          }
          if (dx.needPropagation(direction)) {
--- 121,125 ----
          // XXX: already tested ??
          if (dx.isEmpty()) {
!           throw LowlevelUnsatisfiable.instance;
          }
          if (dx.needPropagation(direction)) {

Index: K0.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/K0.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** K0.java	16 Feb 2005 22:34:49 -0000	1.24
--- K0.java	29 Mar 2005 15:33:02 -0000	1.25
***************
*** 826,830 ****
      if (x == -1) {
        if (!unit) {
!         throw new LowlevelUnsatisfiable();
        }
      } else if (x < m) {
--- 826,830 ----
      if (x == -1) {
        if (!unit) {
!         throw LowlevelUnsatisfiable.instance;
        }
      } else if (x < m) {
***************
*** 832,836 ****
        // is condensed on the rigid variables)
        if (!set.get(x)) {
!         throw new LowlevelUnsatisfiable();
        }
      } else {
--- 832,836 ----
        // is condensed on the rigid variables)
        if (!set.get(x)) {
!         throw LowlevelUnsatisfiable.instance;
        }
      } else {
***************
*** 1106,1110 ****
        if (T.includedIn(m, R) != null) {
          // T is NOT included in R on [0, m[ x [0, m[
!         throw new LowlevelUnsatisfiable();// will be refined if necessary
        }
      }
--- 1106,1110 ----
        if (T.includedIn(m, R) != null) {
          // T is NOT included in R on [0, m[ x [0, m[
!         throw LowlevelUnsatisfiable.instance; // will be refined if necessary
        }
      }

Index: LowlevelUnsatisfiable.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/LowlevelUnsatisfiable.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** LowlevelUnsatisfiable.java	14 Jun 2000 13:32:53 -0000	1.1
--- LowlevelUnsatisfiable.java	29 Mar 2005 15:33:03 -0000	1.2
***************
*** 17,20 ****
--- 17,22 ----
    }
    
+   static LowlevelUnsatisfiable instance = new LowlevelUnsatisfiable();
+ 
    static boolean refinedReports = true;
    public static void setRefinedReports(boolean flag) {

Index: Satisfier.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/Satisfier.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Satisfier.java	14 Jun 2000 13:32:55 -0000	1.1
--- Satisfier.java	29 Mar 2005 15:33:03 -0000	1.2
***************
*** 18,22 ****
--- 18,24 ----
  
    private static boolean satisfiable = false;
+ 
    private static class Satisfiable extends Exception {}
+   private static Satisfiable sat = new Satisfiable();
  
    private static void enumerate(int[] strategy, DomainVector domains,
***************
*** 40,44 ****
  
          // backtrack
!         throw new Satisfiable();
        }
      }
--- 42,46 ----
  
          // backtrack
!         throw sat;
        }
      }
***************
*** 66,70 ****
        }
      }
!     throw new LowlevelUnsatisfiable();
    }
    
--- 68,72 ----
        }
      }
!     throw LowlevelUnsatisfiable.instance;
    }
    
***************
*** 82,89 ****
        satisfiable = true;
        if (handler == null) {
!         throw new Satisfiable();
        }
        handler.handle(domains);
!       throw new LowlevelUnsatisfiable();
      }
      Domain dx = (Domain)domains.getDomain(x).clone();
--- 84,91 ----
        satisfiable = true;
        if (handler == null) {
!         throw sat;
        }
        handler.handle(domains);
!       throw LowlevelUnsatisfiable.instance;
      }
      Domain dx = (Domain)domains.getDomain(x).clone();
***************
*** 98,102 ****
  
          // XXX: reachable ?
!         throw new Satisfiable();
        }
        catch (LowlevelUnsatisfiable _) {
--- 100,104 ----
  
          // XXX: reachable ?
!         throw sat;
        }
        catch (LowlevelUnsatisfiable _) {
***************
*** 104,108 ****
        }
      }
!     throw new LowlevelUnsatisfiable();
    }
      
--- 106,110 ----
        }
      }
!     throw LowlevelUnsatisfiable.instance;
    }
      

Index: Domain.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/Domain.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Domain.java	6 Sep 2003 11:31:10 -0000	1.4
--- Domain.java	29 Mar 2005 15:33:02 -0000	1.5
***************
*** 81,85 ****
      this.containsUnit &= unit; 
      if (this.isEmpty()) {
!       throw new LowlevelUnsatisfiable();
      }
    }
--- 81,85 ----
      this.containsUnit &= unit; 
      if (this.isEmpty()) {
!       throw LowlevelUnsatisfiable.instance;
      }
    }
***************
*** 92,96 ****
      this.andNot(set);
      if (this.isEmpty()) {
!       throw new LowlevelUnsatisfiable();
      }
    }
--- 92,96 ----
      this.andNot(set);
      if (this.isEmpty()) {
!       throw LowlevelUnsatisfiable.instance;
      }
    }
***************
*** 103,107 ****
      this.containsUnit = false;
      if (this.isEmpty()) {
!       throw new LowlevelUnsatisfiable();
      }
    }
--- 103,107 ----
      this.containsUnit = false;
      if (this.isEmpty()) {
!       throw LowlevelUnsatisfiable.instance;
      }
    }
***************
*** 118,122 ****
      }
      if (this.isEmpty()) {
!       throw new LowlevelUnsatisfiable();
      }
    }
--- 118,122 ----
      }
      if (this.isEmpty()) {
!       throw LowlevelUnsatisfiable.instance;
      }
    }
***************
*** 147,151 ****
          return -1;
        } else {
!         throw new LowlevelUnsatisfiable();
        }
      }
--- 147,151 ----
          return -1;
        } else {
!         throw LowlevelUnsatisfiable.instance;
        }
      }
***************
*** 170,174 ****
    public void instantiate(int value) throws LowlevelUnsatisfiable {
      if (!containsValue(value)) {
!       throw new LowlevelUnsatisfiable();
      }
      clearAll();
--- 170,174 ----
    public void instantiate(int value) throws LowlevelUnsatisfiable {
      if (!containsValue(value)) {
!       throw LowlevelUnsatisfiable.instance;
      }
      clearAll();



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click