Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] remove recursive get type support, search operations are local in the type...
authorLucas Schnorr <Lucas.Schnorr@imag.fr>
Mon, 23 Jan 2012 13:01:01 +0000 (14:01 +0100)
committerLucas Schnorr <Lucas.Schnorr@imag.fr>
Mon, 23 Jan 2012 13:01:01 +0000 (14:01 +0100)
src/instr/instr_paje_types.c
src/instr/instr_private.h

index c8f0ee2..48320cc 100644 (file)
@@ -98,36 +98,36 @@ void PJ_type_free_all (void)
   }
 }
 
   }
 }
 
-static type_t recursiveGetType (const char *name, type_t root)
+type_t PJ_type_get (const char *name, type_t father)
 {
 {
-  if (name == NULL || root == NULL){
-    THROWF (tracing_error, 0, "can't get type with a NULL name (or a NULL father given)");
+  type_t ret = PJ_type_get_or_null (name, father);
+  if (ret == NULL){
+    THROWF (tracing_error, 2, "type with name (%s) not found in father type (%s)", name, father->name);
   }
   }
+  return ret;
+}
 
 
-  if (strcmp (root->name, name) == 0) return root;
+type_t PJ_type_get_or_null (const char *name, type_t father)
+{
+  if (name == NULL || father == NULL){
+    THROWF (tracing_error, 0, "can't get type with a NULL name or from a NULL father");
+  }
 
 
-  xbt_dict_cursor_t cursor = NULL;
-  type_t child;
+  type_t ret = NULL, child;
   char *child_name;
   char *child_name;
-  type_t ret = NULL;
-  xbt_dict_foreach(root->children, cursor, child_name, child) {
-    type_t found = recursiveGetType(name, child);
-    if (found){
-      if (ret == NULL){
-        ret = found;
+  xbt_dict_cursor_t cursor = NULL;
+  xbt_dict_foreach(father->children, cursor, child_name, child) {
+    if (strcmp (child->name, name) == 0){
+      if (ret != NULL){
+        THROWF (tracing_error, 0, "there are two children types with the same name?");
       }else{
       }else{
-        THROWF(tracing_error, 0, "found two types with the same name");
+        ret = child;
       }
     }
   }
   return ret;
 }
 
       }
     }
   }
   return ret;
 }
 
-type_t PJ_type_get (const char *name, type_t father)
-{
-  return recursiveGetType (name, father);
-}
-
 type_t PJ_type_container_new (const char *name, type_t father)
 {
   if (name == NULL){
 type_t PJ_type_container_new (const char *name, type_t father)
 {
   if (name == NULL){
index cd3be85..740bd2d 100644 (file)
@@ -221,6 +221,7 @@ type_t PJ_type_variable_new (const char *name, const char *color, type_t father)
 type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t dest);
 type_t PJ_type_state_new (const char *name, type_t father);
 type_t PJ_type_get (const char *name, const type_t father);
 type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t dest);
 type_t PJ_type_state_new (const char *name, type_t father);
 type_t PJ_type_get (const char *name, const type_t father);
+type_t PJ_type_get_or_null (const char *name, type_t father);
 void PJ_type_free (type_t type);
 void PJ_type_free_all (void);
 
 void PJ_type_free (type_t type);
 void PJ_type_free_all (void);