From: bdemsky Date: Tue, 24 Mar 2009 00:39:14 +0000 (+0000) Subject: improve performance X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9ce51126e9ec2ccb43a27a4182b4514cbe46b59a;p=IRC.git improve performance --- diff --git a/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java b/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java index 6b30e1ba..06eb4503 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java +++ b/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java @@ -43,9 +43,13 @@ public class TokenTuple extends Canonical { } private void fixStuff() { - if (!isMultiObject) { - arity=ARITY_ONE; - } + //This is an evil hack...we should fix this stuff elsewhere... + if (!isMultiObject) { + arity=ARITY_ONE; + } else { + if (arity==ARITY_ONEORMORE) + arity=ARITY_ZEROORMORE; + } } @@ -117,23 +121,8 @@ public class TokenTuple extends Canonical { arity == tt.getArity(); } - private boolean oldHashSet = false; - private int oldHash = 0; public int hashCode() { - int currentHash = token.intValue()*31 + arity; - - if( oldHashSet == false ) { - oldHash = currentHash; - oldHashSet = true; - } else { - if( oldHash != currentHash ) { - System.out.println("IF YOU SEE THIS A CANONICAL TokenTuple CHANGED"); - Integer x = null; - x.toString(); - } - } - - return currentHash; + return (token.intValue() << 2) ^ arity; } diff --git a/Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java b/Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java index 5b60afea..13fa65ea 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java +++ b/Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java @@ -159,25 +159,17 @@ public class TokenTupleSet extends Canonical { return tokenTuples.equals(tts.tokenTuples); } + boolean hashcodecomputed; + int ourhashcode; - private boolean oldHashSet = false; - private int oldHash = 0; public int hashCode() { - int currentHash = tokenTuples.hashCode(); - - if( oldHashSet == false ) { - oldHash = currentHash; - oldHashSet = true; - } else { - if( oldHash != currentHash ) { - System.out.println("IF YOU SEE THIS A CANONICAL TokenTupleSet CHANGED"); - Integer x = null; - x.toString(); + if (hashcodecomputed) + return ourhashcode; + else { + ourhashcode=tokenTuples.hashCode(); + return ourhashcode; } - } - - return currentHash; }