model: move bookkeeping to add_action_to_lists()
authorBrian Norris <banorris@uci.edu>
Mon, 28 May 2012 19:58:56 +0000 (12:58 -0700)
committerBrian Norris <banorris@uci.edu>
Mon, 28 May 2012 19:58:56 +0000 (12:58 -0700)
I keep a lot of bookkeeping info for efficiently locating ModelActions (e.g.,
in lists, maps, vectors). Let's just perform the dirty calculations in a single
function to help separate logical functions a little better.

model.cc
model.h

index 0a08717ba45d9c51e5873bf64d11b2e2a5b9cac6..142ae3efdfab1bf0812350a5fc89d37ea45c21b9 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -222,14 +222,20 @@ void ModelChecker::check_current_action(void)
                        next_backtrack = curr;
 
        set_backtracking(curr);
-       this->action_trace->push_back(curr);
 
-       std::vector<action_list_t> *vec = &(*obj_thrd_map)[curr->get_location()];
-       if (id_to_int(curr->get_tid()) >= (int)vec->size())
+       add_action_to_lists(curr);
+}
+
+void ModelChecker::add_action_to_lists(ModelAction *act)
+{
+       action_trace->push_back(act);
+
+       std::vector<action_list_t> *vec = &(*obj_thrd_map)[act->get_location()];
+       if (id_to_int(act->get_tid()) >= (int)vec->size())
                vec->resize(next_thread_id);
-       (*vec)[id_to_int(curr->get_tid())].push_back(curr);
+       (*vec)[id_to_int(act->get_tid())].push_back(act);
 
-       (*thrd_last_action)[id_to_int(curr->get_tid())] = curr;
+       (*thrd_last_action)[id_to_int(act->get_tid())] = act;
 }
 
 ModelAction * ModelChecker::get_last_action(thread_id_t tid)
diff --git a/model.h b/model.h
index 1f22ebfc40737b2ec1e8cb41000ef820a06f6d5b..b59e29cea19b660935824eca736178183910c735 100644 (file)
--- a/model.h
+++ b/model.h
@@ -56,6 +56,7 @@ private:
        ModelAction * get_next_backtrack();
        void reset_to_initial_state();
 
+       void add_action_to_lists(ModelAction *act);
        ModelAction * get_last_action(thread_id_t tid);
 
        void print_list(action_list_t *list);