From: Brian Norris Date: Mon, 28 May 2012 19:58:56 +0000 (-0700) Subject: model: move bookkeeping to add_action_to_lists() X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=551ed6f7408e5376b3ea355997e378a1f2387e69;p=c11tester.git model: move bookkeeping to add_action_to_lists() 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. --- diff --git a/model.cc b/model.cc index 0a08717b..142ae3ef 100644 --- 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 *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 *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 1f22ebfc..b59e29ce 100644 --- 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);