Compacting the methods
authorSeyed Amir Hossein Aqajari <saqajari@circinus-48.ics.uci.edu>
Sat, 7 Dec 2019 00:25:17 +0000 (16:25 -0800)
committerSeyed Amir Hossein Aqajari <saqajari@circinus-48.ics.uci.edu>
Sat, 7 Dec 2019 00:25:17 +0000 (16:25 -0800)
src/main/gov/nasa/jpf/listener/ConflictTracker.java

index 8c1e2afd5715035880b48bc52a2a1f5efe80313c..82a71147943f905265e4113ee6b204a8b3f38d29 100644 (file)
@@ -118,15 +118,9 @@ public class ConflictTracker extends ListenerAdapter {
       // Check if the node has changed or not
       if (isChanged) {
        // Check for a conflict in all the transition out of this node
       // Check if the node has changed or not
       if (isChanged) {
        // Check for a conflict in all the transition out of this node
-        for (Node node : nodeToProcess.getSuccessors()) {
-         HashMap<Transition, ArrayList<NameValuePair>> setSets = nodeToProcess.getOutgoingEdges().get(node).getSetSetMap();
-         for (Map.Entry mapElement : setSets.entrySet()) {
-           Transition transition = (Transition)mapElement.getKey();
-           if (checkForConflict(nodeToProcess, node, transition))
-             return true;
-         }
-        }
-       
+       if (checkAllSuccForConflict(nodeToProcess))
+         return true;
+        
        // Update the parents list for the successors of the current node
        parents.clear();
        parents.add(nodeToProcess);
        // Update the parents list for the successors of the current node
        parents.clear();
        parents.add(nodeToProcess);
@@ -157,6 +151,18 @@ public class ConflictTracker extends ListenerAdapter {
     return message;
   }
 
     return message;
   }
 
+  boolean checkAllSuccForConflict(Node currentNode) {
+    for (Node node : currentNode.getSuccessors()) {
+      HashMap<Transition, ArrayList<NameValuePair>> setSets = currentNode.getOutgoingEdges().get(node).getSetSetMap();
+      for (Map.Entry mapElement : setSets.entrySet()) {
+        Transition transition = (Transition)mapElement.getKey();
+       if (checkForConflict(currentNode, node, transition))
+         return true;
+      }
+    }
+    return false;
+  }
+
   boolean checkForConflict(Node parentNode, Node currentNode, Transition currentTransition) {
     ArrayList<NameValuePair> setSet = parentNode.getOutgoingEdges().get(currentNode).getSetSetMap().get(currentTransition);
     HashMap<String, String> valueMap = new HashMap<String, String>(); // HashMap from varName to value
   boolean checkForConflict(Node parentNode, Node currentNode, Transition currentTransition) {
     ArrayList<NameValuePair> setSet = parentNode.getOutgoingEdges().get(currentNode).getSetSetMap().get(currentTransition);
     HashMap<String, String> valueMap = new HashMap<String, String>(); // HashMap from varName to value
@@ -484,16 +490,9 @@ public class ConflictTracker extends ListenerAdapter {
     boolean isChanged = updateTheOutSet(parentNode, currentNode);
 
     // Check if the outSet of this state has changed, update all of its successors' sets if any
     boolean isChanged = updateTheOutSet(parentNode, currentNode);
 
     // Check if the outSet of this state has changed, update all of its successors' sets if any
-    if (isChanged) {
-      for (Node node : currentNode.getSuccessors()) {
-        HashMap<Transition, ArrayList<NameValuePair>> setSets = currentNode.getOutgoingEdges().get(node).getSetSetMap();
-       for (Map.Entry mapElement : setSets.entrySet()) {
-         Transition currentTransition = (Transition)mapElement.getKey();
-         conflictFound = conflictFound || checkForConflict(currentNode, node, currentTransition);
-       }
-      }
-      conflictFound = conflictFound || propagateTheChange(currentNode);
-    }
+    if (isChanged)
+      conflictFound = conflictFound || checkAllSuccForConflict(currentNode) || propagateTheChange(currentNode);
+    
     // Update the parent node
     if (nodes.containsKey(id)) {
       parentNode = nodes.get(id);
     // Update the parent node
     if (nodes.containsKey(id)) {
       parentNode = nodes.get(id);