Directly use pmap_get() instead of pmap_contains() + pmap_get().
authorChristoph Mallon <christoph.mallon@gmx.de>
Thu, 12 Jul 2012 15:26:04 +0000 (17:26 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Fri, 13 Jul 2012 21:03:55 +0000 (23:03 +0200)
ir/ana/trouts.c
ir/ir/irdump.c

index d6aeddd..c0740c2 100644 (file)
@@ -53,12 +53,10 @@ static pmap *type_arraytype_map = NULL;
  */
 static ir_node **get_entity_access_array(const ir_entity *ent)
 {
-       ir_node **res;
        if (!entity_access_map) entity_access_map = pmap_create();
 
-       if (pmap_contains(entity_access_map, ent)) {
-               res = pmap_get(ir_node*, entity_access_map, ent);
-       } else {
+       ir_node **res = pmap_get(ir_node*, entity_access_map, ent);
+       if (!res) {
                res = NEW_ARR_F(ir_node *, 0);
                pmap_insert(entity_access_map, ent, (void *)res);
        }
@@ -77,12 +75,10 @@ static void set_entity_access_array(const ir_entity *ent, ir_node **accs)
  */
 static ir_node **get_entity_reference_array(const ir_entity *ent)
 {
-       ir_node **res;
        if (!entity_reference_map) entity_reference_map = pmap_create();
 
-       if (pmap_contains(entity_reference_map, ent)) {
-               res = pmap_get(ir_node*, entity_reference_map, ent);
-       } else {
+       ir_node **res = pmap_get(ir_node*, entity_reference_map, ent);
+       if (!res) {
                res = NEW_ARR_F(ir_node *, 0);
                pmap_insert(entity_reference_map, ent, (void *)res);
        }
@@ -101,12 +97,10 @@ static void set_entity_reference_array(const ir_entity *ent, ir_node **refs)
  */
 static ir_node **get_type_alloc_array(const ir_type *tp)
 {
-       ir_node **res;
        if (!type_alloc_map) type_alloc_map = pmap_create();
 
-       if (pmap_contains(type_alloc_map, tp)) {
-               res = pmap_get(ir_node*, type_alloc_map, tp);
-       } else {
+       ir_node **res = pmap_get(ir_node*, type_alloc_map, tp);
+       if (!res) {
                res = NEW_ARR_F(ir_node *, 0);
                pmap_insert(type_alloc_map, tp, (void *)res);
        }
@@ -125,12 +119,10 @@ static void set_type_alloc_array(const ir_type *tp, ir_node **alls)
  */
 static ir_node **get_type_cast_array(const ir_type *tp)
 {
-       ir_node **res;
        if (!type_cast_map) type_cast_map = pmap_create();
 
-       if (pmap_contains(type_cast_map, tp)) {
-               res = pmap_get(ir_node*, type_cast_map, tp);
-       } else {
+       ir_node **res = pmap_get(ir_node*, type_cast_map, tp);
+       if (!res) {
                res = NEW_ARR_F(ir_node *, 0);
                pmap_insert(type_cast_map, tp, (void *)res);
        }
@@ -148,12 +140,10 @@ static void set_type_cast_array(const ir_type *tp, ir_node **alls)
  */
 static ir_type **get_type_pointertype_array(const ir_type *tp)
 {
-       ir_type **res;
        if (!type_pointertype_map) type_pointertype_map = pmap_create();
 
-       if (pmap_contains(type_pointertype_map, tp)) {
-               res = pmap_get(ir_type*, type_pointertype_map, tp);
-       } else {
+       ir_type **res = pmap_get(ir_type*, type_pointertype_map, tp);
+       if (!res) {
                res = NEW_ARR_F(ir_type *, 0);
                pmap_insert(type_pointertype_map, tp, (void *)res);
        }
@@ -172,12 +162,10 @@ static void set_type_pointertype_array(const ir_type *tp, ir_type **pts)
  */
 static ir_type **get_type_arraytype_array(const ir_type *tp)
 {
-       ir_type **res;
        if (!type_arraytype_map) type_arraytype_map = pmap_create();
 
-       if (pmap_contains(type_arraytype_map, tp)) {
-               res = pmap_get(ir_type*, type_arraytype_map, tp);
-       } else {
+       ir_type **res = pmap_get(ir_type*, type_arraytype_map, tp);
+       if (!res) {
                res = NEW_ARR_F(ir_type *, 0);
                pmap_insert(type_arraytype_map, tp, (void *)res);
        }
index 5e59695..311af7b 100644 (file)
@@ -469,13 +469,10 @@ static void init_irdump(void)
  */
 static void *ird_get_irn_link(const ir_node *n)
 {
-       void *res = NULL;
        if (irdump_link_map == NULL)
                return NULL;
 
-       if (pmap_contains(irdump_link_map, n))
-               res = pmap_get(void, irdump_link_map, n);
-       return res;
+       return pmap_get(void, irdump_link_map, n);
 }
 
 /**
@@ -493,13 +490,10 @@ static void ird_set_irn_link(const ir_node *n, void *x)
  */
 static void *ird_get_irg_link(const ir_graph *irg)
 {
-       void *res = NULL;
        if (irdump_link_map == NULL)
                return NULL;
 
-       if (pmap_contains(irdump_link_map, irg))
-               res = pmap_get(void, irdump_link_map, irg);
-       return res;
+       return pmap_get(void, irdump_link_map, irg);
 }
 
 /**