[Nice-commit] Nice/src/mlsub/typing/lowlevel Satisfier.java,1.2,1.3 K0.java,1.25,1.26 DomainVector.j
Brought to you by:
bonniot
|
From: Daniel B. <bo...@us...> - 2005-03-29 22:52:07
|
Update of /cvsroot/nice/Nice/src/mlsub/typing/lowlevel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11424/src/mlsub/typing/lowlevel Modified Files: Satisfier.java K0.java DomainVector.java Domain.java BitVector.java BitMatrix.java Log Message: Optim: do not use Object.clone to clone BitVectors. Index: Domain.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/Domain.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Domain.java 29 Mar 2005 15:33:02 -0000 1.5 --- Domain.java 29 Mar 2005 22:51:57 -0000 1.6 *************** *** 223,225 **** --- 223,239 ---- return result; } + + public Domain cloneDomain() { + Domain result = new Domain(0); + this.copyTo(result); + return result; + } + + private void copyTo(Domain result) { + super.copyTo(result); + + result.containsUnit = containsUnit; + result.cardUp = cardUp; + result.cardDown = cardDown; + } } Index: DomainVector.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/DomainVector.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DomainVector.java 29 Mar 2005 15:33:02 -0000 1.4 --- DomainVector.java 29 Mar 2005 22:51:57 -0000 1.5 *************** *** 98,102 **** Domain d = ((Domain)elementData[i]); if (d != null) { ! result.elementData[i] = (Domain)d.clone(); } } --- 98,102 ---- Domain d = ((Domain)elementData[i]); if (d != null) { ! result.elementData[i] = d.cloneDomain(); } } Index: Satisfier.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/Satisfier.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Satisfier.java 29 Mar 2005 15:33:03 -0000 1.2 --- Satisfier.java 29 Mar 2005 22:51:57 -0000 1.3 *************** *** 45,49 **** } } ! Domain dx = (Domain)domains.getDomain(x).clone(); for (int a = dx.getLowestSetBit(); a >= 0; --- 45,49 ---- } } ! Domain dx = domains.getDomain(x).cloneDomain(); for (int a = dx.getLowestSetBit(); a >= 0; *************** *** 89,93 **** throw LowlevelUnsatisfiable.instance; } ! Domain dx = (Domain)domains.getDomain(x).clone(); // iterate through the elements of dx for (int a = dx.getLowestSetBit(); --- 89,93 ---- throw LowlevelUnsatisfiable.instance; } ! Domain dx = domains.getDomain(x).cloneDomain(); // iterate through the elements of dx for (int a = dx.getLowestSetBit(); Index: BitVector.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/BitVector.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** BitVector.java 17 Apr 2004 17:12:11 -0000 1.10 --- BitVector.java 29 Mar 2005 22:51:57 -0000 1.11 *************** *** 15,19 **** allocating the array) **/ ! public class BitVector implements Cloneable, java.io.Serializable { private final static int BITS_PER_UNIT = 6; private final static int MASK = (1<<BITS_PER_UNIT)-1; --- 15,19 ---- allocating the array) **/ ! public class BitVector implements java.io.Serializable { private final static int BITS_PER_UNIT = 6; private final static int MASK = (1<<BITS_PER_UNIT)-1; *************** *** 526,537 **** * Clones the BitVector. */ ! final public Object clone() { ! BitVector result = null; ! try { ! result = (BitVector) super.clone(); ! } catch (CloneNotSupportedException e) { ! throw new InternalError("this shouldn't happen, since we are Cloneable"); ! } if (bits1 == null) result.bits0 = bits0; --- 526,536 ---- * Clones the BitVector. */ ! public BitVector cloneVector() { ! BitVector result = new BitVector(); ! this.copyTo(result); ! return result; ! } + public void copyTo(BitVector result) { if (bits1 == null) result.bits0 = bits0; *************** *** 543,547 **** System.arraycopy(bits1, 0, result.bits1, 0, n); } - return result; } --- 542,545 ---- Index: K0.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/K0.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** K0.java 29 Mar 2005 15:33:02 -0000 1.25 --- K0.java 29 Mar 2005 22:51:57 -0000 1.26 *************** *** 1272,1276 **** for (int iid = 0; iid < nInterfaces(); iid++) { BitVector I_impls = getInterface(iid).implementors; ! rigidImplementors[iid] = (BitVector)I_impls.clone(); for (int x = I_impls.getLowestSetBit(); x != BitVector.UNDEFINED_INDEX; --- 1272,1276 ---- for (int iid = 0; iid < nInterfaces(); iid++) { BitVector I_impls = getInterface(iid).implementors; ! rigidImplementors[iid] = I_impls.cloneVector(); for (int x = I_impls.getLowestSetBit(); x != BitVector.UNDEFINED_INDEX; *************** *** 1358,1362 **** this.savedC = (BitMatrix) K0.this.C.clone(); ! this.savedGarbage = (BitVector)K0.this.garbage.clone(); this.savedDomains = (DomainVector)K0.this.domains.clone(); /* --- 1358,1362 ---- this.savedC = (BitMatrix) K0.this.C.clone(); ! this.savedGarbage = K0.this.garbage.cloneVector(); this.savedDomains = (DomainVector)K0.this.domains.clone(); /* Index: BitMatrix.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/BitMatrix.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** BitMatrix.java 6 Apr 2003 19:00:17 -0000 1.8 --- BitMatrix.java 29 Mar 2005 22:51:58 -0000 1.9 *************** *** 286,290 **** cyclicmask.set(index[tempsp]); } while (index[tempsp--] != nextbitpos); ! current = (BitVector)current.clone(); current.andNot(cyclicmask); bitpos[stackpos] = 0; --- 286,290 ---- cyclicmask.set(index[tempsp]); } while (index[tempsp--] != nextbitpos); ! current = current.cloneVector(); current.andNot(cyclicmask); bitpos[stackpos] = 0; *************** *** 331,335 **** if (row != null) { if (!row.isEmpty()) ! v[i] = (BitVector) row.clone(); else v[i] = null; --- 331,335 ---- if (row != null) { if (!row.isEmpty()) ! v[i] = row.cloneVector(); else v[i] = null; |