Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Do not create a dict for every resource especially when it is empty anyway.
authorNavarrop <Pierre.Navarro@imag.fr>
Mon, 12 Dec 2011 13:37:44 +0000 (14:37 +0100)
committerNavarrop <Pierre.Navarro@imag.fr>
Fri, 16 Dec 2011 15:58:01 +0000 (16:58 +0100)
src/surf/surfxml_parse.c

index c1bcc92..06aaa82 100644 (file)
@@ -253,29 +253,30 @@ void ETag_surfxml_platform(void){
 }
 
 void STag_surfxml_host(void){
 }
 
 void STag_surfxml_host(void){
-  s_sg_platf_host_cbarg_t host;
-  memset(&host,0,sizeof(host));
-
   xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
   xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
-  host.properties = current_property_set = xbt_dict_new_homogeneous(xbt_free_f);
-
-       host.id = A_surfxml_host_id;
-       host.power_peak = get_cpu_power(A_surfxml_host_power);
-       host.power_scale = surf_parse_get_double( A_surfxml_host_availability);
-       host.core_amount = surf_parse_get_int(A_surfxml_host_core);
-       host.power_trace = tmgr_trace_new(A_surfxml_host_availability_file);
-       host.state_trace = tmgr_trace_new(A_surfxml_host_state_file);
-       xbt_assert((A_surfxml_host_state == A_surfxml_host_state_ON) ||
-                         (A_surfxml_host_state == A_surfxml_host_state_OFF), "Invalid state");
-       if (A_surfxml_host_state == A_surfxml_host_state_ON)
-               host.initial_state = SURF_RESOURCE_ON;
-       if (A_surfxml_host_state == A_surfxml_host_state_OFF)
-               host.initial_state = SURF_RESOURCE_OFF;
-       host.coord = A_surfxml_host_coordinates;
-
-       sg_platf_new_host(&host);
 }
 }
+
 void ETag_surfxml_host(void)    {
 void ETag_surfxml_host(void)    {
+  s_sg_platf_host_cbarg_t host;
+  memset(&host,0,sizeof(host));
+
+  host.properties = current_property_set;
+
+  host.id = A_surfxml_host_id;
+  host.power_peak = get_cpu_power(A_surfxml_host_power);
+  host.power_scale = surf_parse_get_double( A_surfxml_host_availability);
+  host.core_amount = surf_parse_get_int(A_surfxml_host_core);
+  host.power_trace = tmgr_trace_new(A_surfxml_host_availability_file);
+  host.state_trace = tmgr_trace_new(A_surfxml_host_state_file);
+  xbt_assert((A_surfxml_host_state == A_surfxml_host_state_ON) ||
+        (A_surfxml_host_state == A_surfxml_host_state_OFF), "Invalid state");
+  if (A_surfxml_host_state == A_surfxml_host_state_ON)
+    host.initial_state = SURF_RESOURCE_ON;
+  if (A_surfxml_host_state == A_surfxml_host_state_OFF)
+    host.initial_state = SURF_RESOURCE_OFF;
+  host.coord = A_surfxml_host_coordinates;
+
+  sg_platf_new_host(&host);
   current_property_set = NULL;
 }
 
   current_property_set = NULL;
 }
 
@@ -363,47 +364,48 @@ void ETag_surfxml_peer(void){
   /* nothing to do here */
 }
 void STag_surfxml_link(void){
   /* nothing to do here */
 }
 void STag_surfxml_link(void){
-  s_sg_platf_link_cbarg_t link;
-  memset(&link,0,sizeof(link));
-
   xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
   xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
-  link.properties = current_property_set = xbt_dict_new_homogeneous(xbt_free_f);
-
-       link.id = A_surfxml_link_id;
-       link.bandwidth = surf_parse_get_double(A_surfxml_link_bandwidth);
-       link.bandwidth_trace = tmgr_trace_new(A_surfxml_link_bandwidth_file);
-       link.latency = surf_parse_get_double(A_surfxml_link_latency);
-       link.latency_trace = tmgr_trace_new(A_surfxml_link_latency_file);
-
-       switch (A_surfxml_link_state) {
-       case A_surfxml_link_state_ON:
-               link.state = SURF_RESOURCE_ON;
-               break;
-       case A_surfxml_link_state_OFF:
-               link.state = SURF_RESOURCE_OFF;
-               break;
-       default:
-         surf_parse_error(bprintf("invalid state for link %s",link.id));
-       }
-       link.state_trace = tmgr_trace_new(A_surfxml_link_state_file);
-
-       switch (A_surfxml_link_sharing_policy) {
-       case A_surfxml_link_sharing_policy_SHARED:
-               link.policy = SURF_LINK_SHARED;
-               break;
-       case A_surfxml_link_sharing_policy_FATPIPE:
-                link.policy = SURF_LINK_FATPIPE;
-                break;
-       case A_surfxml_link_sharing_policy_FULLDUPLEX:
-                link.policy = SURF_LINK_FULLDUPLEX;
-                break;
-       default:
-         surf_parse_error(bprintf("Invalid sharing policy in link %s",link.id));
-       }
-
-       sg_platf_new_link(&link);
 }
 void ETag_surfxml_link(void){
 }
 void ETag_surfxml_link(void){
+  s_sg_platf_link_cbarg_t link;
+  memset(&link,0,sizeof(link));
+
+  link.properties = current_property_set;
+
+  link.id = A_surfxml_link_id;
+  link.bandwidth = surf_parse_get_double(A_surfxml_link_bandwidth);
+  link.bandwidth_trace = tmgr_trace_new(A_surfxml_link_bandwidth_file);
+  link.latency = surf_parse_get_double(A_surfxml_link_latency);
+  link.latency_trace = tmgr_trace_new(A_surfxml_link_latency_file);
+
+  switch (A_surfxml_link_state) {
+  case A_surfxml_link_state_ON:
+    link.state = SURF_RESOURCE_ON;
+    break;
+  case A_surfxml_link_state_OFF:
+    link.state = SURF_RESOURCE_OFF;
+    break;
+  default:
+    surf_parse_error(bprintf("invalid state for link %s",link.id));
+  }
+  link.state_trace = tmgr_trace_new(A_surfxml_link_state_file);
+
+  switch (A_surfxml_link_sharing_policy) {
+  case A_surfxml_link_sharing_policy_SHARED:
+    link.policy = SURF_LINK_SHARED;
+    break;
+  case A_surfxml_link_sharing_policy_FATPIPE:
+     link.policy = SURF_LINK_FATPIPE;
+     break;
+  case A_surfxml_link_sharing_policy_FULLDUPLEX:
+     link.policy = SURF_LINK_FULLDUPLEX;
+     break;
+  default:
+    surf_parse_error(bprintf("Invalid sharing policy in link %s",link.id));
+  }
+
+  sg_platf_new_link(&link);
+
   current_property_set = NULL;
 }
 
   current_property_set = NULL;
 }
 
@@ -443,8 +445,6 @@ void STag_surfxml_bypassRoute(void){
 void STag_surfxml_config(void){
   XBT_DEBUG("START configuration name = %s",A_surfxml_config_id);
   xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
 void STag_surfxml_config(void){
   XBT_DEBUG("START configuration name = %s",A_surfxml_config_id);
   xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
-  current_property_set = xbt_dict_new_homogeneous(xbt_free_f);
-
 }
 void ETag_surfxml_config(void){
   xbt_dict_cursor_t cursor = NULL;
 }
 void ETag_surfxml_config(void){
   xbt_dict_cursor_t cursor = NULL;