clean up check code
authorBrian Demsky <bdemsky@uci.edu>
Sat, 3 Nov 2012 09:54:08 +0000 (02:54 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Sat, 3 Nov 2012 09:54:08 +0000 (02:54 -0700)
nodestack.cc

index 22cc378..743cb86 100644 (file)
@@ -161,21 +161,14 @@ bool Node::increment_promise() {
  * @return true if we have explored all promise combinations.
  */
 bool Node::promise_empty() {
  * @return true if we have explored all promise combinations.
  */
 bool Node::promise_empty() {
-       unsigned int rmw_count=0;
-       for (unsigned int i = 0; i < promises.size(); i++) {
-               if (promises[i]==(PROMISE_RMW|PROMISE_FULFILLED))
-                       rmw_count++;
-       }
-
-       for (unsigned int i = 0; i < promises.size();i++) {
-               if ((promises[i]& PROMISE_MASK) == PROMISE_UNFULFILLED) {
-                       //if this isn't a feasible option, keep going
-                       if ((rmw_count > 0)&&(promises[i] & PROMISE_RMW))
-                               continue;
+       bool fulfilledrmw=false;
+       for (int i = promises.size()-1 ; i>=0; i--) {
+               if (promises[i]==PROMISE_UNFULFILLED)
                        return false;
                        return false;
-               } else if (promises[i] == (PROMISE_RMW|PROMISE_FULFILLED)) {
-                       rmw_count--;
-               }
+               if (!fulfilledrmw && ((promises[i]&PROMISE_MASK)==PROMISE_UNFULFILLED))
+                       return false;
+               if (promises[i]==(PROMISE_FULFILLED|PROMISE_RMW))
+                       fulfilledrmw=true;
        }
        return true;
 }
        }
        return true;
 }