promise: refactor has_failed()
authorBrian Norris <banorris@uci.edu>
Wed, 23 Jan 2013 20:50:57 +0000 (12:50 -0800)
committerBrian Norris <banorris@uci.edu>
Wed, 23 Jan 2013 20:50:57 +0000 (12:50 -0800)
has_failed() can simply call the thread_is_eliminated() function which
does much of the same computation already. We can drop the
'((int)i != promise_tid)' clause, since the 'promise_tid' thread must
already be eliminated.

promise.cc

index 7f6f5e7b1823bb5dd3285196ba57f4ee172b0f37..016b809aefaacf0d6e38e0674e60b89503bb3d31 100644 (file)
@@ -44,12 +44,10 @@ bool Promise::thread_is_eliminated(thread_id_t tid) const
  */
 bool Promise::has_failed() const
 {
-       unsigned int size = eliminated_thread.size();
-       int promise_tid = id_to_int(read->get_tid());
        for (unsigned int i = 1; i < model->get_num_threads(); i++) {
-               if ((i >= size || !eliminated_thread[i]) && ((int)i != promise_tid) && model->is_enabled(int_to_id(i))) {
+               thread_id_t tid = int_to_id(i);
+               if (!thread_is_eliminated(tid) && model->is_enabled(tid))
                        return false;
-               }
        }
        return true;
 }