changeset 19002:3be6793b4549

Fix LocationSet - use equals for comparing LocationIdentity objects.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 28 Jan 2015 11:27:35 +0100
parents 5a79fa76b489
children 0bcb0dae2c52
files graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java
diffstat 1 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Wed Jan 28 04:05:07 2015 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Wed Jan 28 11:27:35 2015 +0100
@@ -101,14 +101,24 @@
         }
 
         public void add(LocationIdentity location) {
-            if (location == LocationIdentity.ANY_LOCATION) {
+            if (LocationIdentity.ANY_LOCATION.equals(location)) {
                 firstLocation = location;
                 list = null;
             } else {
                 if (firstLocation == null) {
                     firstLocation = location;
+                } else if (LocationIdentity.ANY_LOCATION.equals(firstLocation)) {
+                    return;
+                } else if (location.equals(firstLocation)) {
+                    return;
                 } else {
                     initList();
+                    for (int i = 0; i < list.size(); ++i) {
+                        LocationIdentity value = list.get(i);
+                        if (location.equals(value)) {
+                            return;
+                        }
+                    }
                     list.add(location);
                 }
             }
@@ -128,18 +138,18 @@
 
         public boolean contains(LocationIdentity locationIdentity) {
             assert locationIdentity != null;
-            assert locationIdentity != LocationIdentity.ANY_LOCATION;
-            assert locationIdentity != LocationIdentity.FINAL_LOCATION;
-            if (firstLocation == LocationIdentity.ANY_LOCATION) {
+            assert !locationIdentity.equals(LocationIdentity.ANY_LOCATION);
+            assert !locationIdentity.equals(LocationIdentity.FINAL_LOCATION);
+            if (LocationIdentity.ANY_LOCATION.equals(firstLocation)) {
                 return true;
             }
-            if (firstLocation == locationIdentity) {
+            if (locationIdentity.equals(firstLocation)) {
                 return true;
             }
             if (list != null) {
                 for (int i = 0; i < list.size(); ++i) {
                     LocationIdentity value = list.get(i);
-                    if (value == locationIdentity) {
+                    if (locationIdentity.equals(value)) {
                         return true;
                     }
                 }