[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[imp-commit] r22981 - trunk/org.eclipse.imp.pdb.values/src/org/eclipse/imp/pdb/facts/impl/util/collections

Author: jvinju
Date: 2012-07-28 02:19:34 -0400 (Sat, 28 Jul 2012)
New Revision: 22981

Modified:
   trunk/org.eclipse.imp.pdb.values/src/org/eclipse/imp/pdb/facts/impl/util/collections/ShareableValuesHashMap.java
Log:
* reuse a value that was already assigned to a local var. (thx Bob!)
* added some curlies

Modified: trunk/org.eclipse.imp.pdb.values/src/org/eclipse/imp/pdb/facts/impl/util/collections/ShareableValuesHashMap.java
===================================================================
--- trunk/org.eclipse.imp.pdb.values/src/org/eclipse/imp/pdb/facts/impl/util/collections/ShareableValuesHashMap.java	2012-07-26 11:26:58 UTC (rev 22980)
+++ trunk/org.eclipse.imp.pdb.values/src/org/eclipse/imp/pdb/facts/impl/util/collections/ShareableValuesHashMap.java	2012-07-28 06:19:34 UTC (rev 22981)
@@ -356,14 +356,21 @@
 	}
 	
 	public boolean isEqual(ShareableValuesHashMap other){
-		if(other == null) return false;
-		if(other.currentHashCode != currentHashCode) return false;
-		if(other.size() != size()) return false;
+		if(other == null) {
+			return false;
+		}
+		if(other.currentHashCode != currentHashCode) { 
+			return false;
+		}
+		if(other.size() != size()) {
+			return false;
+		}
+		if(isEmpty()) {
+			return true; // No need to check if the maps are empty.
+		}
 		
-		if(isEmpty()) return true; // No need to check if the maps are empty.
-		
 		Iterator<Map.Entry<IValue, IValue>> otherIterator = other.entryIterator();
-		while(otherIterator.hasNext()){
+		while (otherIterator.hasNext()) {
 			Map.Entry<IValue, IValue> entry = otherIterator.next();
 			IValue otherValue = entry.getValue();
 			IValue thisValue = get(entry.getKey());
@@ -375,10 +382,11 @@
 			
 			if(otherValue != thisValue 
 					&& thisValue != null 
-					&& !thisValue.isEqual(entry.getValue())) {
+					&& !thisValue.isEqual(otherValue)) {
 				return false;
 			}
 		}
+		
 		return true;
 	}