Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace_mgr] cosmetics: only declare variables on need
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 30 Jan 2016 23:27:03 +0000 (00:27 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 30 Jan 2016 23:57:05 +0000 (00:57 +0100)
src/surf/trace_mgr.cpp

index d6839e3..43a0a6c 100644 (file)
@@ -404,24 +404,19 @@ tmgr_trace_iterator_t simgrid::trace_mgr::future_evt_set::pop_leq(
     double date, double *value, simgrid::surf::Resource **resource)
 {
   double event_date = next_date();
-  tmgr_trace_iterator_t trace_iterator = NULL;
-  tmgr_event_t event = NULL;
-  tmgr_trace_t trace = NULL;
-  double event_delta;
-
   if (event_date > date)
     return NULL;
 
-  if (!(trace_iterator = (tmgr_trace_iterator_t)xbt_heap_pop(p_heap)))
+  tmgr_trace_iterator_t trace_iterator = (tmgr_trace_iterator_t)xbt_heap_pop(p_heap);
+  if (trace_iterator == NULL)
     return NULL;
 
-  trace = trace_iterator->trace;
+  tmgr_trace_t trace = trace_iterator->trace;
   *resource = trace_iterator->resource;
 
-  switch(trace->type) {
-    case e_trace_list:
+  if (trace->type == e_trace_list) {
 
-      event = (tmgr_event_t)xbt_dynar_get_ptr(trace->s_list.event_list, trace_iterator->idx);
+      tmgr_event_t event = (tmgr_event_t)xbt_dynar_get_ptr(trace->s_list.event_list, trace_iterator->idx);
 
       *value = event->value;
 
@@ -434,11 +429,9 @@ tmgr_trace_iterator_t simgrid::trace_mgr::future_evt_set::pop_leq(
       } else {                      /* We don't need this trace_event anymore */
         trace_iterator->free_me = 1;
       }
-      break;
-
-    case e_trace_probabilist:
 
-      //FIXME : not tested yet
+  } else if (trace->type == e_trace_probabilist) { //FIXME : not tested yet
+      double event_delta;
       if(trace->s_probabilist.is_state_trace) {
         *value = (double) trace->s_probabilist.next_event;
         if(trace->s_probabilist.next_event == 0) {
@@ -455,8 +448,8 @@ tmgr_trace_iterator_t simgrid::trace_mgr::future_evt_set::pop_leq(
       xbt_heap_push(p_heap, trace_iterator, event_date + event_delta);
       XBT_DEBUG("Generating a new event at date %f, with value %f", event_date + event_delta, *value);
 
-      break;
-  }
+  } else
+    THROW_IMPOSSIBLE;
 
   return trace_iterator;
 }