From: Martin Quinson Date: Sun, 14 May 2017 22:12:29 +0000 (+0200) Subject: tmgr: kill a function that only calls the constructor X-Git-Tag: v3.16~274^2~17 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d0eda33bb0ecc60027d1c00ab6dfd655d2829913 tmgr: kill a function that only calls the constructor --- diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 8dc0926b71..e3b612a688 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -424,7 +424,7 @@ void CpuTi::setSpeedTrace(tmgr_trace_t trace) if (trace && trace->event_list.size() > 1) { trace_mgr::DatedValue val = trace->event_list.back(); if (val.date_ < 1e-12) - speed_.event = future_evt_set->add_trace(tmgr_empty_trace_new(), this); + speed_.event = future_evt_set->add_trace(new simgrid::trace_mgr::trace(), this); } } diff --git a/src/surf/trace_mgr.cpp b/src/surf/trace_mgr.cpp index b9fdbb9796..89f9ef1f8c 100644 --- a/src/surf/trace_mgr.cpp +++ b/src/surf/trace_mgr.cpp @@ -44,7 +44,12 @@ std::ostream& operator<<(std::ostream& out, const DatedValue& e) return out; } -trace::trace() = default; +trace::trace() +{ + /* Add the first fake event storing the time at which the trace begins */ + tmgr::DatedValue val(0, -1); + event_list.push_back(val); +} trace::~trace() = default; future_evt_set::future_evt_set() = default; simgrid::trace_mgr::future_evt_set::~future_evt_set() @@ -57,11 +62,11 @@ simgrid::trace_mgr::future_evt_set::~future_evt_set() tmgr_trace_t tmgr_trace_new_from_string(const char* name, std::string input, double periodicity) { int linecount = 0; - tmgr::DatedValue* last_event; + tmgr_trace_t trace = new simgrid::trace_mgr::trace(); + tmgr::DatedValue* last_event = &(trace->event_list.back()); xbt_assert(trace_list.find(name) == trace_list.end(), "Refusing to define trace %s twice", name); - tmgr_trace_t trace = new simgrid::trace_mgr::trace(); std::vector list; boost::split(list, input, boost::is_any_of("\n\r")); @@ -79,17 +84,11 @@ tmgr_trace_t tmgr_trace_new_from_string(const char* name, std::string input, dou xbt_assert(sscanf(val.c_str(), "%lg %lg\n", &event.date_, &event.value_) == 2, "%s:%d: Syntax error in trace\n%s", name, linecount, input.c_str()); - if (last_event) { - xbt_assert(last_event->date_ <= event.date_, - "%s:%d: Invalid trace: Events must be sorted, but time %g > time %g.\n%s", name, linecount, - last_event->date_, event.date_, input.c_str()); + xbt_assert(last_event->date_ <= event.date_, + "%s:%d: Invalid trace: Events must be sorted, but time %g > time %g.\n%s", name, linecount, + last_event->date_, event.date_, input.c_str()); + last_event->date_ = event.date_ - last_event->date_; - last_event->date_ = event.date_ - last_event->date_; - } else { - /* Add the first fake event storing the time at which the trace begins */ - tmgr::DatedValue first_event(event.date_, -1.0); - trace->event_list.push_back(first_event); - } trace->event_list.push_back(event); last_event = &(trace->event_list.back()); } @@ -123,15 +122,6 @@ tmgr_trace_t tmgr_trace_new_from_file(const char *filename) return trace; } -tmgr_trace_t tmgr_empty_trace_new() -{ - tmgr_trace_t trace = new simgrid::trace_mgr::trace(); - tmgr::DatedValue val(0, 0); - trace->event_list.push_back(val); - - return trace; -} - void tmgr_trace_free(tmgr_trace_t trace) { delete trace; diff --git a/src/surf/trace_mgr.hpp b/src/surf/trace_mgr.hpp index 5e19d547ce..f21bfe3283 100644 --- a/src/surf/trace_mgr.hpp +++ b/src/surf/trace_mgr.hpp @@ -23,7 +23,6 @@ typedef struct tmgr_trace_event { typedef struct tmgr_trace_event* tmgr_trace_event_t; /* Creation functions */ -XBT_PUBLIC(tmgr_trace_t) tmgr_empty_trace_new(void); XBT_PUBLIC(void) tmgr_trace_free(tmgr_trace_t trace); /** * \brief Free a trace event structure @@ -79,7 +78,7 @@ XBT_PUBLIC_CLASS trace_event{ XBT_PUBLIC_CLASS trace { public: /** Creates an empty trace */ - trace(); + explicit trace(); virtual ~trace(); //private: std::vector event_list;